Add fast path for integer strings in variable name comparator#8483
Merged
APickledWalrus merged 3 commits intoSkriptLang:dev/featurefrom Mar 27, 2026
Merged
Conversation
0965004 to
f6fac44
Compare
UnderscoreTud
approved these changes
Mar 15, 2026
sovdeeth
added a commit
that referenced
this pull request
Apr 2, 2026
* Add Origin-applying SyntaxRegistry (#8376) * Add reduce/fold Expression (#8353) * Location with Yaw/Pitch (#8351) * Test framework: support directory resources (#8377) * Test framework: support directory resources * use walkFileTree * oops forgot imports * Pattern Stringification Customization (#8391) * Implement StringificationProperties * Package cleanup * Fix missing call in GroupPatternElement stringification (#8449) Fix GroupPatternElement stringification * Stabilise damage source experiment (#8414) * Stabilise damage source experiment * Replace STABLE with MAINSTREAM * Remove experiment from damage source test * Remove unstable API usage supression --------- Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> * Add vector(n) (#8412) * Init commit * Fix not registering overloading for old namespaces * Standardize Module usage + add child modules (#8346) * child module support * Create child modules and move over existing Bukkit addon modules. * Update newer modules * Clean up * Requested changes and additional conversions Just tags left! * convert last module * standardize package hierarchies * remove bad imports * fix bad examples * Replace ChildAddonModule with HierarchicalAddonModule, move display/interaction modules into entity module, few other requested changes * requested changes * varargs registrar (thanks blue!) * Use addonmodule javadocs to point to other useful tools * Requested Changes * Requested Changes * Added option to compress file backups (#8396) * Add fast path for integer strings in variable name comparator (#8483) * Initial conversion * Some more conversion * fixes * Update StructCommand.java * no tests --------- Co-authored-by: Patrick Miller <apickledwalrus@icloud.com> Co-authored-by: mibers <midaswoah2@gmail.com> Co-authored-by: _tud <98935832+UnderscoreTud@users.noreply.github.com> Co-authored-by: devdinc <234956748+devdinc@users.noreply.github.com> Co-authored-by: Tiberiu Sabău <96194994+tibisabau@users.noreply.github.com> Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com> Co-authored-by: Pesek <42549665+Pesekjak@users.noreply.github.com>
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.