bruno-roustant commented on code in PR #13368: URL: https://github.com/apache/lucene/pull/13368#discussion_r1600171257
########## lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SuggestibleEntryCache.java: ########## @@ -48,22 +45,33 @@ private SuggestibleEntryCache(Map<Integer, SectionBuilder> builders) { static SuggestibleEntryCache buildCache(WordStorage storage) { var consumer = new Consumer<FlyweightEntry>() { - final Map<Integer, SectionBuilder> builders = new HashMap<>(); + final IntObjectHashMap<SectionBuilder> builders = new IntObjectHashMap<>(); + int maxLength; @Override public void accept(FlyweightEntry entry) { CharsRef root = entry.root(); if (root.length > Short.MAX_VALUE) { throw new UnsupportedOperationException( "Too long dictionary entry, please report this to d...@lucene.apache.org"); + } else if (root.length > maxLength) { + maxLength = root.length; } - builders.computeIfAbsent(root.length, __ -> new SectionBuilder()).add(entry); + SectionBuilder builder; Review Comment: This is the only spot where the replacement brings some complexity. It does not seem too complex to me, so I kept it. -- 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. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org 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