mirror of https://github.com/apache/lucene.git
LUCENE-10452: Hunspell: call checkCanceled less frequently to reduce the overhead (#723)
This commit is contained in:
parent
6b7953b8ce
commit
af97c5ef37
|
@ -77,8 +77,6 @@ class GeneratingSuggester {
|
||||||
Math.max(1, word.length() - 4),
|
Math.max(1, word.length() - 4),
|
||||||
word.length() + 4,
|
word.length() + 4,
|
||||||
(rootChars, forms) -> {
|
(rootChars, forms) -> {
|
||||||
speller.checkCanceled.run();
|
|
||||||
|
|
||||||
assert rootChars.length > 0;
|
assert rootChars.length > 0;
|
||||||
if (Math.abs(rootChars.length - word.length()) > MAX_ROOT_LENGTH_DIFF) {
|
if (Math.abs(rootChars.length - word.length()) > MAX_ROOT_LENGTH_DIFF) {
|
||||||
assert rootChars.length < word.length(); // processAllWords takes care of longer keys
|
assert rootChars.length < word.length(); // processAllWords takes care of longer keys
|
||||||
|
@ -105,6 +103,8 @@ class GeneratingSuggester {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
speller.checkCanceled.run();
|
||||||
|
|
||||||
String root = rootChars.toString();
|
String root = rootChars.toString();
|
||||||
do {
|
do {
|
||||||
roots.add(new Weighted<>(new Root<>(root, forms.ints[forms.offset + suitable]), sc));
|
roots.add(new Weighted<>(new Root<>(root, forms.ints[forms.offset + suitable]), sc));
|
||||||
|
|
|
@ -400,9 +400,10 @@ public class Hunspell {
|
||||||
char[] wordChars, int offset, int length, List<IntsRef> words) {
|
char[] wordChars, int offset, int length, List<IntsRef> words) {
|
||||||
if (words.size() >= 100) return false;
|
if (words.size() >= 100) return false;
|
||||||
|
|
||||||
|
checkCanceled.run();
|
||||||
|
|
||||||
int limit = length - dictionary.compoundMin + 1;
|
int limit = length - dictionary.compoundMin + 1;
|
||||||
for (int breakPos = dictionary.compoundMin; breakPos < limit; breakPos++) {
|
for (int breakPos = dictionary.compoundMin; breakPos < limit; breakPos++) {
|
||||||
checkCanceled.run();
|
|
||||||
IntsRef forms = dictionary.lookupWord(wordChars, offset, breakPos);
|
IntsRef forms = dictionary.lookupWord(wordChars, offset, breakPos);
|
||||||
if (forms != null) {
|
if (forms != null) {
|
||||||
words.add(forms);
|
words.add(forms);
|
||||||
|
|
Loading…
Reference in New Issue