-
Notifications
You must be signed in to change notification settings - Fork 136
Numeric faster #132
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
Numeric faster #132
Conversation
src/tokenizer.rs
Outdated
Some(match_byte! { b, | ||
b'0' ... b'9' => { b - b'0' }, | ||
b'a' ... b'z' => { b - b'a' + 10 }, | ||
b'A' ... b'Z' => { b - b'A' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unusual definition of hexadecimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoopsies, indeed :)
The following commit: * Removes char logic from consume_numeric. * Rearranges exponent parsing to look at one char in the common case (presumably not a big deal). This makes the benchmark added in the first commit go from: test tests::numeric ... bench: 48,221,308 ns/iter (+/- 3,356,881) to: test tests::numeric ... bench: 43,656,802 ns/iter (+/- 1,323,570) on my machine. Which is pretty much a micro-optimization, but perhaps it's worth given how common these values are.
@bors-servo r+ |
📌 Commit 2b6cc13 has been approved by |
Numeric faster The following commit: * Removes char logic from consume_numeric. * Rearranges exponent parsing to look at one char in the common case (presumably not a big deal). This makes the benchmark added in the first commit go from: test tests::numeric ... bench: 48,221,308 ns/iter (+/- 3,356,881) to: test tests::numeric ... bench: 43,656,802 ns/iter (+/- 1,323,570) on my machine. Which is pretty much a micro-optimization, but perhaps it's worth given how common these values are. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/132) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
The following commit:
(presumably not a big deal).
This makes the benchmark added in the first commit go from:
test tests::numeric ... bench: 48,221,308 ns/iter (+/- 3,356,881)
to:
test tests::numeric ... bench: 43,656,802 ns/iter (+/- 1,323,570)
on my machine.
Which is pretty much a micro-optimization, but perhaps it's worth given how
common these values are.
This change is