fix(js-ts): keep the export default Foo; pass linear on comment runs - #24
Merged
Merged
Conversation
DEFAULT_ID_RE matched the whitespace around the line with `\s*`. Comments are blanked to spaces and newlines before it runs, so from every line the leading `\s*` crossed all the blank lines after it before failing: 20,000 comment lines took ~8 s, 50,000 ~33 s. Match horizontal whitespace only and end the line on `\r?\n`, so CRLF files still read.
Contributor
|
🎉 This PR is included in version 2.31.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Problem
DEFAULT_ID_RE(added in 7c4a77f, released in v2.31.0) matched the whitespace around anexport default Foo;/export = Fooline with\s*. The regex tier blanks comments to spaces and newlines before this pass, so from every line the leading\s*crossed all following blank lines before failing. The pass was quadratic: 20,000 comment lines took ~8 s, 50,000 took ~33 s. A 1.2 MB comment-heavy file went from 50 ms on v2.30.1 to ~12 s, and ultrasec's scan-adapter test timed out.Fix
Match horizontal whitespace only (
[ \t]*) at both ends and end the line on\r?\n, so CRLF files still read. The same 50,000-line input now takes a few ms.Tests
regex-tier.test.ts:export default Foo;andexport = Fooin a CRLF file (plus a negativeexport default Foo.bar;)regex-tier.test.ts: 50,000 comment lines scanned in under 1.5 s. This test fails on main (33 s) and passes with the fix.scripts/engine.mjs/scripts/engine.browser.mjssocheck:buildstays clean.