Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Optimized]: Removed several bounds checks
- For the init loop, The compiler is unable to prove that "<= lenS1" is essentially same as "< len(x)". So we mention it explicitly. - Made a dummy bounds check to prevent further checks for x[lenS1] down below. And this also takes care of x[j-1] since j is <= lenS1. This effectively reduces the number of bounds checks from 7 to just 1, which is the dummy call to x[lenS1]. The compiler, as of 1.12, is unable to determine that lenS1 is indeed a positive number. So lenS1+1 will be positive, and hence x[lenS1] should be within bounds of x. As a result, this is unavoidable. name old time/op new time/op delta Simple/ASCII-4 473ns ± 2% 365ns ± 1% -22.85% (p=0.000 n=10+10) Simple/French-4 897ns ± 2% 680ns ± 2% -24.23% (p=0.000 n=10+10) Simple/Nordic-4 1.83µs ± 1% 1.33µs ± 2% -27.23% (p=0.000 n=8+9) Simple/Tibetan-4 1.40µs ± 2% 1.15µs ± 2% -17.56% (p=0.000 n=10+10)
- Loading branch information
Showing
3 changed files
with
10 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
module github.com/agnivade/levenshtein | ||
|
||
go 1.13 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
agnivade
Author
Owner
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Does this version exist yet? Getting build errors related to this as it's an indirect dependency