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

Add benchmarks, small refactors for performance #30

Merged
merged 4 commits into from
Feb 12, 2019
Merged

Add benchmarks, small refactors for performance #30

merged 4 commits into from
Feb 12, 2019

Conversation

boydjohnson
Copy link
Contributor

before

after

To run the benchmarks, run cargo +nightly bench. There are three refactors that make encode and decode faster.

This refactor makes the variable mid local to the loop, instead of
global to the function. It also uses a while loop, instead of checking
if each time through the outer loop.
hash_value_of_char uses the ordinal value of the char and then checks
ranges and subtracts. This saves a linear search of the value in an
array.
@sunng87 sunng87 merged commit 7078734 into georust:master Feb 12, 2019
@sunng87
Copy link
Member

sunng87 commented Feb 12, 2019

Thanks! @boydjohnson

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