Conversation
Reproduces with: node tests/test-parse-perf.js Reports median of 7 runs of 5000 parse() calls on a 200-line .env.
The line-matching regex in parse() is the dominant cost when parsing large .env files. Replaces it with a Uint8Array(256) lookup table for key character classification and a manual state machine over the input string. indexOf() is used to find the end of unquoted values and newline boundaries. Behavior is preserved across the existing test suite and 24 additional edge cases (escaped quotes inside double quotes, unterminated quotes, yaml-style 'KEY: value', export prefix, multiline values, inline comments, KEY==value, etc.). No new dependencies. No changes to public API.
perf: ~2x faster parse() via hand-written character scanner Keep the classic regex parser as default and expose #1010's scanner behind parse(src, { fast: true }) / config({ fast: true }). Co-authored-by: Cursor <cursoragent@cursor.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.
No description provided.