Skip to content

Commit

Permalink
Merge pull request #51 from lithammer/cmov
Browse files Browse the repository at this point in the history
Use `CMOV` instruction to speed up `min()`
  • Loading branch information
lithammer authored Apr 28, 2023
2 parents d7e5d42 + a928105 commit a6d3776
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fuzzy/levenshtein.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ func LevenshteinDistance(s, t string) int {
return column[len(r1)]
}

func min(a, b, c int) int {
if a < b && a < c {
func min2(a, b int) int {
if a < b {
return a
} else if b < c {
return b
}
return c
return b
}

func min(a, b, c int) int {
return min2(min2(a, b), c)
}

0 comments on commit a6d3776

Please sign in to comment.