Skip to content

Commit 79fb777

Browse files
chore: Use faster 3 way string comparison (#292)
1 parent a1696fb commit 79fb777

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

bindings/go/scip/sort.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scip
22

33
import (
44
"sort"
5+
"strings"
56

67
"golang.org/x/exp/slices"
78
)
@@ -24,12 +25,7 @@ func FindSymbol(document *Document, symbolName string) *SymbolInformation {
2425
// and SymbolInformation values must be merged. This guarantee is upheld by CanonicalizeDocument.
2526
func FindSymbolBinarySearch(canonicalizedDocument *Document, symbolName string) *SymbolInformation {
2627
i, found := slices.BinarySearchFunc(canonicalizedDocument.Symbols, symbolName, func(sym *SymbolInformation, lookup string) int {
27-
if sym.Symbol < lookup {
28-
return -1
29-
} else if sym.Symbol == lookup {
30-
return 0
31-
}
32-
return 1
28+
return strings.Compare(sym.Symbol, lookup)
3329
})
3430
if found {
3531
return canonicalizedDocument.Symbols[i]

0 commit comments

Comments
 (0)