-
Notifications
You must be signed in to change notification settings - Fork 374
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
Optimize Levenshtein implementation #427
Conversation
var curCol = nextCol; | ||
|
||
// substution | ||
nextCol = prevRow[j] + ( (str1.charAt(i) === str2.charAt(j)) ? 0 : 1 ); |
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.
The ternary is optional here; coercing to a boolean will work as well
/cc @stoeffel any chance of getting this in and releasing a 3.0.4? |
@megawac sure I will have a look at this tomorrow and publish a new release. |
how about we link to hiddentao (in the readme) since this is directly from his implementation? |
otherwise LGTM. I will check it once again this evening and then hopefully have time to pump the version. |
Optimize Levenshtein implementation
@megawac I published 3.1.0 |
Sweetness thanks! |
Just had to publish again since I accidentally pushed the |
This implementation is directly from https://github.com/hiddentao/fast-levenshtein
Before this change:
After:
Relevant jsperf: http://jsperf.com/levenshtein-distance/22 (I experimented with some of the others but this one had by far the best performance in node)