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

Two micro-opts for lexer #418

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tigercat2000
Copy link
Contributor

Measured about ~150ms faster peek() with the first change.
Measured within-noise for the second change- but it's nicer code so it's still a good change, I think.

@SpaceManiac
Copy link
Owner

150ms must be a typo; did you mean ns? The speedup is within noise parsing an entire codebase on a release build. It seems to me that on -C opt-level=2 or higher, where PartialEq gets inlined, the assembly has a len== check anyways.

Improving the put_back code is good, but you could go even further by moving the let ws = ... inside read_ident and return bool instead of Option<u8>.

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