diff options
author | Felix Lange <fjl@twurst.com> | 2016-10-20 20:56:34 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-10-20 20:56:34 +0800 |
commit | b930baa58078862d082745330038e60d0767026c (patch) | |
tree | 4584574278774fb438948dfe782e6845fab5a791 /Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go | |
parent | 66ee2dec53f9e18b4def0b0005e291fdd810f327 (diff) | |
download | go-tangerine-b930baa58078862d082745330038e60d0767026c.tar go-tangerine-b930baa58078862d082745330038e60d0767026c.tar.gz go-tangerine-b930baa58078862d082745330038e60d0767026c.tar.bz2 go-tangerine-b930baa58078862d082745330038e60d0767026c.tar.lz go-tangerine-b930baa58078862d082745330038e60d0767026c.tar.xz go-tangerine-b930baa58078862d082745330038e60d0767026c.tar.zst go-tangerine-b930baa58078862d082745330038e60d0767026c.zip |
Godeps: update github.com/syndtr/goleveldb to 6b4daa5362
Diffstat (limited to 'Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go index 248bf7c21..448402b82 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go @@ -6,7 +6,9 @@ package leveldb -import "github.com/syndtr/goleveldb/leveldb/comparer" +import ( + "github.com/syndtr/goleveldb/leveldb/comparer" +) type iComparer struct { ucmp comparer.Comparer @@ -33,12 +35,12 @@ func (icmp *iComparer) Name() string { } func (icmp *iComparer) Compare(a, b []byte) int { - x := icmp.ucmp.Compare(internalKey(a).ukey(), internalKey(b).ukey()) + x := icmp.uCompare(internalKey(a).ukey(), internalKey(b).ukey()) if x == 0 { if m, n := internalKey(a).num(), internalKey(b).num(); m > n { - x = -1 + return -1 } else if m < n { - x = 1 + return 1 } } return x @@ -46,30 +48,20 @@ func (icmp *iComparer) Compare(a, b []byte) int { func (icmp *iComparer) Separator(dst, a, b []byte) []byte { ua, ub := internalKey(a).ukey(), internalKey(b).ukey() - dst = icmp.ucmp.Separator(dst, ua, ub) - if dst == nil { - return nil + dst = icmp.uSeparator(dst, ua, ub) + if dst != nil && len(dst) < len(ua) && icmp.uCompare(ua, dst) < 0 { + // Append earliest possible number. + return append(dst, keyMaxNumBytes...) } - if len(dst) < len(ua) && icmp.uCompare(ua, dst) < 0 { - dst = append(dst, keyMaxNumBytes...) - } else { - // Did not close possibilities that n maybe longer than len(ub). - dst = append(dst, a[len(a)-8:]...) - } - return dst + return nil } func (icmp *iComparer) Successor(dst, b []byte) []byte { ub := internalKey(b).ukey() - dst = icmp.ucmp.Successor(dst, ub) - if dst == nil { - return nil - } - if len(dst) < len(ub) && icmp.uCompare(ub, dst) < 0 { - dst = append(dst, keyMaxNumBytes...) - } else { - // Did not close possibilities that n maybe longer than len(ub). - dst = append(dst, b[len(b)-8:]...) + dst = icmp.uSuccessor(dst, ub) + if dst != nil && len(dst) < len(ub) && icmp.uCompare(ub, dst) < 0 { + // Append earliest possible number. + return append(dst, keyMaxNumBytes...) } - return dst + return nil } |