Repository navigation
Codechange: cache seen names in the casefold guard, for performance - #452
Open
andythenorth wants to merge 1 commit into
Open
andythenorth wants to merge 1 commit into
andythenorth wants to merge 1 commit into
Conversation
andythenorth
force-pushed
the
casefold-guard-perf
branch
from
October 18, 2026 12:27
11e8a2a to
5f57643
Compare
PeterN
previously approved these changes
Oct 26, 2026
LordAro
reviewed
Oct 26, 2026
Member
There was a problem hiding this comment.
I'm not sure I follow - item_names is already a dict, why can't that be used, rather than adding a new container?
if self.name.value in global_constants.item_names:
...
else:
casefolded = self.name.value.casefold()
if casefolded in global_constants.item_names:
...
else:
...
(could use := to allow an elif chain)
PeterN
approved these changes
Oct 26, 2026
PeterN
left a comment
Member
There was a problem hiding this comment.
Although item_names is already a dict, the names within it are not casefolded, so I guess a second dict of casefolded names is required
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.
#439 increased pre-processing time from ~4s to ~16s with Iron Horse nml.
The checking of similar names loops all of item names with a comparator. This will be some O(n) complexity that I am not skilled enough to figure out.
This patch puts a crude cache in of already seen names, using dict key lookup, which is usually fast.
With the patch applied, Iron Horse compile is ~4s.
However adding a cache usually means there are now 2 problems. I am unclear if anything else would need to fill or read this cache.