From da0f6c40b901d76b035cd087f1ef9115564145d4 Mon Sep 17 00:00:00 2001 From: Alexey Gopachenko Date: Fri, 27 Aug 2010 19:50:35 +0400 Subject: [PATCH] Spellchecker: just skip words that are too long --- .../intellij/spellchecker/compress/CompressedDictionary.java | 2 ++ .../src/com/intellij/spellchecker/compress/Encoder.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java b/plugins/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java index 4b3be754dae1..14127d894d1e 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/compress/CompressedDictionary.java @@ -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); } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/compress/Encoder.java b/plugins/spellchecker/src/com/intellij/spellchecker/compress/Encoder.java index 543f3fcc07d9..e9ade3511131 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/compress/Encoder.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/compress/Encoder.java @@ -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);