Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(parser): faster offset calculation #2215

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

overlookmotel
Copy link
Collaborator

A faster way to calculate offset in the lexer.

This only moves the needle because it's on the hottest path in the lexer - Lexer::offset is called for every token in Lexer::read_next_token.

@github-actions github-actions bot added the A-parser Area - Parser label Jan 30, 2024
Copy link

codspeed-hq bot commented Jan 30, 2024

CodSpeed Performance Report

Merging #2215 will not alter performance

Comparing overlookmotel:lexer-skip-offset-calc (5c9311b) with main (872d751)

Summary

✅ 17 untouched benchmarks

@Boshen
Copy link
Member

Boshen commented Jan 30, 2024

image

@Boshen
Copy link
Member

Boshen commented Jan 30, 2024

@overlookmotel This is hard to understand without context, can you add some inline comments regarding why this is better than the previous version?

Something like:

// This is changed from self.source.len() - self.current.chars.as_str().len(),
// where ... (bunch of assembly instructions)

@overlookmotel
Copy link
Collaborator Author

Yes sure. Have added a new commit with a comment.

@Boshen Boshen merged commit 81e33a3 into oxc-project:main Jan 30, 2024
20 checks passed
@overlookmotel overlookmotel deleted the lexer-skip-offset-calc branch January 30, 2024 11:14
IWANABETHATGUY pushed a commit to IWANABETHATGUY/oxc that referenced this pull request May 29, 2024
A faster way to calculate offset in the lexer.

This only moves the needle because it's on the hottest path in the lexer
- `Lexer::offset` is called for every token in `Lexer::read_next_token`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area - Parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants