Improve parse perf using bitwise flags - #76
Open
blakeembrey wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #76 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 95 155 +60
Branches 20 40 +20
=========================================
+ Hits 95 155 +60 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
blakeembrey
commented
Aug 24, 2026
| * Skip over characters until a semicolon or other exit character. | ||
| * Remove backslashes from quoted pairs in a known-terminated quoted string body. | ||
| */ | ||
| function skipValue( |
Member
Author
There was a problem hiding this comment.
Inlined skipValue, skipOWS and removing trailingOWS in favor of tracking the last whitespace showed marginal improvements to performance (a few % each).
blakeembrey
commented
Aug 24, 2026
| continue; | ||
| } | ||
|
|
||
| value += String.fromCharCode(code); |
Member
Author
There was a problem hiding this comment.
Unquoting seemed like a large perf improvement with the right conditions (most won't have escapes, turns into a single slice).
blakeembrey
commented
Aug 24, 2026
| } | ||
| const valueEnd = whitespace === -1 ? index : whitespace; | ||
| const value = header.slice(valueStart, valueEnd); | ||
| const type = (typeFlags & CASE_FLAGS) === 0 ? value : value.toLowerCase(); |
Member
Author
There was a problem hiding this comment.
Skipping toLowerCase was the largest perf win when the value is already lower cased.
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.
Before:
After:
I think I might be able to combine these flags with the validation logic to also improve that performance.