diff --git a/autocomplete/autocomplete.go b/autocomplete/autocomplete.go index f58b6af..0332e29 100644 --- a/autocomplete/autocomplete.go +++ b/autocomplete/autocomplete.go @@ -20,13 +20,9 @@ type Set[V any] struct { // The behavior is undefined if the key already has a value. func (s *Set[V]) Add(key string, val V) { k := util.ToChars([]byte(key)) - i, ok := slices.BinarySearchFunc(s.keys, k, func(a, b util.Chars) int { + i, _ := slices.BinarySearchFunc(s.keys, k, func(a, b util.Chars) int { return bytes.Compare(a.Bytes(), b.Bytes()) }) - if ok { - s.vals[i] = val - return - } s.keys = slices.Insert(s.keys, i, k) s.vals = slices.Insert(s.vals, i, val) }