Skip to content

Commit

Permalink
Merge pull request #38 from harrison3000/faster_levenshtein
Browse files Browse the repository at this point in the history
Reduce the number of allocations on the LevenshteinDistance function
  • Loading branch information
lithammer authored May 3, 2022
2 parents e2080d7 + 7734883 commit 61128a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fuzzy/levenshtein.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ package fuzzy
// http://en.wikibooks.org/wiki/Algorithm_implementation/Strings/Levenshtein_distance#C
func LevenshteinDistance(s, t string) int {
r1, r2 := []rune(s), []rune(t)
column := make([]int, len(r1)+1)
column := make([]int, 1, 64)

for y := 1; y <= len(r1); y++ {
column[y] = y
column = append(column, y)
}

for x := 1; x <= len(r2); x++ {
Expand Down

0 comments on commit 61128a1

Please sign in to comment.