perf: O(1) blacklist lookup in BlacklistStorage.isListed - #38
Open
iamthealfaandtheomega wants to merge 1 commit into
Open
iamthealfaandtheomega wants to merge 1 commit into
iamthealfaandtheomega wants to merge 1 commit into
Conversation
Keep the existing HashSet membership but add precomputed raw + first-arg-normalized lookup sets so the hot path is a single O(1) contains for both verbatim and first-arg (takeFirstArgument) matches, fixing the case where main's approach could miss first-arg-stripped queries against full stored entries. - Locale.ROOT normalization (was default-locale toLowerCase()). - transient volatile sets, atomically swapped after full build (no empty/partial set visible to concurrent readers). - dirty-flag defers the O(n) rebuild off add()/remove()/clear() (bulk O(1)/op). - synchronized mutations + iteration; clear() also clears hiddenCommands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Optimizes
BlacklistStorage.isListed(), the hot path behindPlayerCommandSendEvent. The membership check stays O(1)HashSet, but the query lookup now uses precomputed raw + first-arg-normalized sets so both the verbatim and thetakeFirstArgumentpath match correctly against full stored entries.What changed
rawLookup(verbatim) andfirstArgLookup(first-arg-normalized) caches derived fromhiddenCommands.contains()— no scan.rebuildLookups()builds into local sets and atomically swaps the references only after full population (a concurrent reader never sees an empty/partial set).Locale.ROOTnormalization (was default-localetoLowerCase()— locale-sensitive).add()/remove()/clear()→ bulk imports stay O(1) per mutation.synchronized; caches aretransient volatile.clear()now also clearshiddenCommands(was leaving the cache stale).Behavior preserved
turn), case sensitivity, plugin-command expansion, and theload()pipeline (unchanged).Verification
getFirstArg+ lookup normalization invariance.-Xlint:deprecation/-Xlint:unchecked(only pre-existing warnings elsewhere).