Repository navigation
Alter parseString to accumulate StringBuilder appends vs individual calls - #34
Merged
Merged
Conversation
Contributor
Author
|
fasterParsington fork has this in main. |
ctrueden
force-pushed
the
parseString
branch
from
November 17, 2026 20:25
38596cf to
e33c6bb
Compare
An empty range append is a no-op, so the length checks are unnecessary. And since every escape sequence resets the segment start before the next backslash or quote is reached, the -1 sentinel is unnecessary too. Quick benchmark results (STRING token in LiteralsBenchmark): ┌─────────────────────────────────┬─────────────────┬────────────────┐ │ Version │ Time per call │ Change vs main │ ├─────────────────────────────────┼─────────────────┼────────────────┤ │ main (7f21508) │ 35.16 ± 0.16 ns │ — │ │ First commit alone (b3bfe8b) │ 32.12 ± 0.19 ns │ −8.6% │ │ With the tidy-ups (this commit) │ 27.35 ± 0.31 ns │ −22.2% │ └─────────────────────────────────┴─────────────────┴────────────────┘ Settings were the same each time: 3 forks, 5 warmup and 10 measured iterations of 2 seconds each, with the GC profiler on. Assisted-by: Claude Code (Opus 5.5)
Escapes adjacent to the closing quote, consecutive escapes, empty strings, verbatim single-quoted strings, and the final position after parsing a string containing escapes. Assisted-by: Claude Code (Opus 5.5)
ctrueden
force-pushed
the
parseString
branch
from
November 17, 2026 20:43
e33c6bb to
d7a569b
Compare
Contributor
Author
|
Interesting. I used Claude to speed up the parseString today and got a different answer. It passes the tests (and the new ones added here) I have not pushed it yet in the fork nor done a benchmark run. |
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.
Code change to batch StringBuilder appends vs one per character.
Benchmark of STRING("'hello world'") shows a 36% improvement .
It passes the existing tests and my test batch. It needs another set of eyes on it before it is trusted.