Skip to content

Commit

Permalink
reduce the number of allocations on LevenshteinDistance
Browse files Browse the repository at this point in the history
  • Loading branch information
harrison3000 committed May 2, 2022
1 parent e2080d7 commit 7734883
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 7734883

Please sign in to comment.