Add fast path for integer strings in variable name comparator#8483
Open
sovdeeth wants to merge 2 commits intoSkriptLang:dev/featurefrom
Open
Add fast path for integer strings in variable name comparator#8483sovdeeth wants to merge 2 commits intoSkriptLang:dev/featurefrom
sovdeeth wants to merge 2 commits intoSkriptLang:dev/featurefrom
Conversation
0965004 to
f6fac44
Compare
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.
Problem
Setting large lists is still quite a lot slower than it really should be. Setting a 1000 integer list 10,000 times on my pc takes 30 seconds. That should take less than a second, ideally. This is due to variables being backed by a sorted TreeMap with a custom comparator, which is called multiple times for every get/set relating to lists.
Solution
Adds a faster path in the custom comparator, which handles pure integer indices about twice as fast. It adds slight overhead to non-int indices, but since it fails fast it's only really relevant for lists with mixed indices and indices like
1235a, which are likely rather rare. My test case went from 30s to 12.7s to run.I originally was going to optimize the full path, but to get the same performance made the code very hard to read and maintain, and for not a ton of benefit, since int indices are by far the most common.
Also adds tests for index sorting. Some of the behavior is really really weird. Why does
a-2come beforea-1? Because the -2 is smaller than the -1!!! of course!!! don't ask why0001is larger than1!Part 2: Made splitVariableName much faster by throwing out regex and using indexOf instead.
Testing Completed
list ordering.sk
Supporting Information
Benchmark:
Completes: none
Related: none
AI assistance: Claude code, for initial optimization possibilities and for improvements to the indexOf splitting method.