Spellchecker: just skip words that are too long

This commit is contained in:
Alexey Gopachenko
2010-08-27 20:40:58 +04:00
parent 5b5088220a
commit da0f6c40b9
2 changed files with 5 additions and 1 deletions
@@ -121,6 +121,7 @@ public final class CompressedDictionary implements Dictionary {
}
try {
UnitBitSet bs = encoder.encode(word, false);
if (bs == null) return false;
byte[] compressed = UnitBitSet.getBytes(bs);
int index = -1;
for (int i = 0; i < lengths.length; i++) {
@@ -179,6 +180,7 @@ public final class CompressedDictionary implements Dictionary {
String transformed = transform.transform(s);
if (transformed != null) {
UnitBitSet bs = encoder.encode(transformed, true);
if (bs == null) return;
byte[] compressed = UnitBitSet.getBytes(bs);
dictionary.addToDictionary(compressed);
}
@@ -1,6 +1,7 @@
package com.intellij.spellchecker.compress;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.text.MessageFormat;
@@ -21,8 +22,9 @@ public final class Encoder {
return alphabet;
}
@Nullable
public UnitBitSet encode(@NotNull CharSequence letters, boolean force) throws EncodingException {
assert UnitBitSet.MAX_CHARS_IN_WORD >= letters.length() : "Word is too long ";
if (UnitBitSet.MAX_CHARS_IN_WORD >= letters.length()) return null;
UnitBitSet bs = new UnitBitSet();
for (int i = 0; i < letters.length() - 1 + 1; i++) {
char letter = letters.charAt(i);