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

Performance of hamming() can be improved #4

Merged
merged 1 commit into from Aug 12, 2016
Merged

Conversation

IBUzPE9
Copy link
Contributor

@IBUzPE9 IBUzPE9 commented Aug 2, 2016

....chars().count() iterates over whole string. It can be avoided.

tests::new_same_len ... bench:       4,756 ns/iter (+/- 74)
tests::old_same_len ... bench:       7,089 ns/iter (+/- 400)

tests::new_diff_len ... bench:       4,867 ns/iter (+/- 136)
tests::old_diff_len ... bench:       3,024 ns/iter (+/- 90)

`....chars().count()` iterates over whole string. It can be avoided.
@dguo dguo merged commit 1c37418 into rapidfuzz:master Aug 12, 2016
@dguo
Copy link
Member

dguo commented Aug 12, 2016

Thank you!

jnqnfe added a commit to jnqnfe/strsim-rs that referenced this pull request Nov 4, 2018
`usize` implements copy, thus we should prefer copying rather than cloning,
as recommended by the std documentation
jnqnfe added a commit to jnqnfe/strsim-rs that referenced this pull request Nov 4, 2018
jnqnfe added a commit to jnqnfe/strsim-rs that referenced this pull request Nov 8, 2018
Taking the j-w optimisations further, this makes use of the prefix
splitting helper within the inner Jaro algorithm.

The function has been modified such that instead of taking a char-count of
the size of the common prefix removed from the pair of strings, it now
optionally takes a pointer to return the count, obtaining it within the
function through use of the helper internally.

Using the prefix splitting helper within the function means that we avoid
doing a `.chars().count()` iteration over the prefix twice, once going
over `a` and once going over `b`. It also then allows the main part of the
algorithm to completely avoid processing the common prefix portion of the
strings.
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.

None yet

2 participants