Update gtree_btree.go

bugfix: avoid overflow
This commit is contained in:
None
2020-11-05 22:44:09 +08:00
committed by GitHub
parent 176dcdc7cc
commit 1072ea3fb0

View File

@ -620,7 +620,7 @@ func (tree *BTree) middle() int {
func (tree *BTree) search(node *BTreeNode, key interface{}) (index int, found bool) {
low, mid, high := 0, 0, len(node.Entries)-1
for low <= high {
mid = (high + low) / 2
mid = low + int((high-low)/2)
compare := tree.getComparator()(key, node.Entries[mid].Key)
switch {
case compare > 0: