- for i := 0; i < len(u.numbers); i++ {
- if num.identifier == u.numbers[i].identifier {
- return i
- }
- }
- return -1 // This should be unreachable.
+ // Since getIndex() is only ever called on 'num' which already exists in
+ // the universe, we return the result directly, without bothering to
+ // confirm an exact match.
+ //
+ // Also, we can get away with a direct comparison of these floating point
+ // numbers since there will be an exact match, guaranteed since 'num' is
+ // already in the universe.
+ return sort.Search(u.cardinality(), func(i int) bool {return u.numbers[i].value >= num.value})