donnerpeter commented on a change in pull request #4:
URL: https://github.com/apache/lucene/pull/4#discussion_r591653654



##########
File path: 
lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/GeneratingSuggester.java
##########
@@ -102,17 +115,28 @@
     return roots.stream().sorted().collect(Collectors.toList());
   }
 
-  private void filterSuitableEntries(String word, IntsRef forms, 
List<Root<String>> result) {
-    result.clear();
-    for (int i = 0; i < forms.length; i += dictionary.formStep()) {
-      int entryId = forms.ints[forms.offset + i];
-      if (dictionary.hasFlag(entryId, dictionary.forbiddenword)
-          || dictionary.hasFlag(entryId, dictionary.noSuggest)
-          || dictionary.hasFlag(entryId, Dictionary.HIDDEN_FLAG)
-          || dictionary.hasFlag(entryId, dictionary.onlyincompound)) {
-        continue;
+  private static class EntryFilter {
+    private final int formStep;
+    private final FlagEnumerator.Lookup flagLookup;
+    private final char[] excludeFlags;
+
+    EntryFilter(Dictionary dic) {
+      formStep = dic.formStep();
+      flagLookup = dic.flagLookup;
+
+      Character[] flags = {HIDDEN_FLAG, dic.noSuggest, dic.forbiddenword, 
dic.onlyincompound};
+      excludeFlags =
+          Dictionary.toSortedCharArray(
+              Stream.of(flags).filter(c -> c != 
FLAG_UNSET).collect(Collectors.toSet()));
+    }
+
+    int findSuitableFormIndex(IntsRef forms, int start) {
+      for (int i = start; i < forms.length; i += formStep) {
+        if (!flagLookup.hasAnyFlag(forms.ints[forms.offset + i], 
excludeFlags)) {

Review comment:
       Here we check up to 4 flags at once




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to