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
[email protected]");
+ } 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]