tdebatty / java-string-similarity

Implementation of various string similarity and distance algorithms: Levenshtein, Jaro-winkler, n-Gram, Q-Gram, Jaccard index, Longest Common Subsequence edit distance, cosine similarity ...
Other
2.69k stars 413 forks source link

Performance: avoid spurious containsKey calls #26

Closed JPMoresmau closed 7 years ago

JPMoresmau commented 7 years ago

I found some instances where we call containsKey and then get, while doing get and checking for null result is faster (only one hashmap lookup). For Damerau, we are checking if a key exists but anyway we always init with the same value.

Great library, thanks a million for your work!

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.3%) to 66.562% when pulling 990161d81f7af69d483cd0d7b3400e05591d92d7 on JPMoresmau:perf/containskey into d9439d65c2241138fa722a80b684b176980aef81 on tdebatty:master.

tdebatty commented 7 years ago

Thank you for your contribution!