Skip to content

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

Merged
merged 2 commits into from
Apr 9, 2017
Merged

Numeric faster #132

merged 2 commits into from
Apr 9, 2017

Conversation

emilio
Copy link
Member

@emilio emilio commented Apr 7, 2017

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.


This change is Reviewable

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' },
Copy link
Member

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.

Copy link
Member Author

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.
@SimonSapin
Copy link
Member

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 2b6cc13 has been approved by SimonSapin

@bors-servo
Copy link
Contributor

⌛ Testing commit 2b6cc13 with merge a22151d...

bors-servo pushed a commit that referenced this pull request Apr 9, 2017
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 -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-travis
Approved by: SimonSapin
Pushing a22151d to master...

@bors-servo bors-servo merged commit 2b6cc13 into servo:master Apr 9, 2017
@SimonSapin SimonSapin mentioned this pull request Jun 25, 2017
@emilio emilio deleted the numeric-faster branch August 24, 2023 13:17
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.

4 participants