Repository navigation
Add performance improvements to core - #1596
Merged
Merged
Conversation
Member
Author
|
Added one more: |
eriksvedang
approved these changes
Oct 16, 2026
eriksvedang
left a comment
Collaborator
There was a problem hiding this comment.
Very nice, thanks a lot for this!
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.
this pr adds a bunch of performance improvements to core:
String.starts-with?andString.ends-with?now compare bytes. They used to decode the whole string into chars, and now compare bytes and stop at the first mismatch. This also fixes(starts-with? "ölheller" "öl"), which returnedfalse. I measured9.4µs → 0.1µson a 4KB string.Array.swap!now moves instead of copying, because it used to make two copies and two deletes per swap. Heapsort (one of the consumers) on 2k strings:1.22ms → 0.36msput!:3.2ms → 59µsMap.update-value!/Map.value-ref!into core fromweb,. They pass a reference to the stored value without copying it.String.split-by,slice,prefix,suffix/split-byranstrlenon the whole string once per separator, solinesandwordswere accidentally quadratic. Also,slicedecoded the whole string. Both are now single byte scans.lineson 90KB went from18msto0.25ms.Array.map-reduce,slice,remove-nth:map-reducecopied its result array on every step.slicegrew its result per element.remove-nthcopied every element after nth. 10kmap-reduce:2.86ms → ~1µsstron Map, Set, and Bag each entry used to copy the whole string built so far. They now collect the pieces and join them once. 1.68ms → 0.45ms on 2k-entryMap.str.Added a whole bunch of tests.
Cheers