Skip to content

perf(parser): Avoid quadratic identifier column lookup - #1630

Merged
saghul merged 2 commits into
quickjs-ng:masterfrom
bai:cache-identifier-line-start
Aug 4, 2026
Merged

perf(parser): Avoid quadratic identifier column lookup#1630
saghul merged 2 commits into
quickjs-ng:masterfrom
bai:cache-identifier-line-start

Conversation

@bai

@bai bai commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

#1585 introduced O(n^2) regression for minified single-line sources. Remove the backward scan and maintain a line start pointer in the lexer to make it O(1).

(With a 277KB minified single-line file perf regression I was seeing was 38x.)

@saghul

saghul commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR! Looks like this mechanism should also be applied in js_parse_error. Also, could you please add a test?

@bai

bai commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Looks like this mechanism should also be applied in js_parse_error

Good catch, pushed.

@saghul
saghul merged commit 0e19436 into quickjs-ng:master Aug 4, 2026
128 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants