Bulk-scan single-line string bodies#491
Merged
Merged
Conversation
421172e to
e08a656
Compare
This was referenced Jun 6, 2026
Contributor
|
@tfoutrein please resolve the conflicts |
Parsing a single-line string appended its body one character at a time (`value += current; inc()`). For long string values this dominates. Scan the run of ordinary characters up to the next delimiter, backslash or control character in a single pass (`Source.advance_until`) and append the whole slice at once; the stop character is then handled by the existing branch on the next iteration. Multiline strings keep the per-character loop (CRLF handling). The stop-set is exactly the control characters the per-character loop rejects, so InvalidControlChar / escape / delimiter handling is unchanged. No behaviour change (972 tests incl. the toml-test conformance submodule; plus a 4135-input adversarial differential — output and error-type byte-identical to the per-char loop). Up to ~5x faster parsing on string-heavy single-line documents.
e08a656 to
1ec5f04
Compare
Contributor
Author
|
Rebased onto |
frostming
approved these changes
Jun 10, 2026
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.
What
Parsing a single-line string appended its body one character at a time (
value += current; inc()). For long string values (the bulk of most config / lockfile content) this dominates.This scans the run of ordinary characters up to the next delimiter, backslash or control character in a single pass (
Source.advance_until) and appends the whole slice at once; the stop character is then handled by the existing branch on the next iteration. Multiline strings keep the per-character loop (CRLF handling).The stop-set is exactly the control characters the per-character loop rejects, so
InvalidControlChar/ escape / delimiter handling is unchanged, and a mid-string EOF raisesUnexpectedEofErrorjust as the per-charinc(exception=...)did.Benchmarks
Parsing speedup across document shapes (median, interleaved A/B vs
master, includes #489+#490):No regression on any shape (multiline-heavy and nested docs are unchanged).
Tests
Full suite passes (972 tests, incl. the toml-test conformance submodule). On top of that, a 4135-input adversarial differential (random escapes valid+invalid, every control byte 0x00–0x1F+DEL in basic & literal, unicode/astral/combining, the other-quote char inside strings, truncated/malformed inputs for error parity) is byte-identical in output and exception type to the per-character loop. No public API or behaviour change.