simplify cursor2stream

This commit is contained in:
alex.sharov 2023-01-17 14:42:47 +07:00
parent bfca37c869
commit 1fb7e7ae77

View File

@ -1782,14 +1782,14 @@ func (s *cursor2stream) HasNext() bool {
cmp := bytes.Compare(s.nextK, s.toPrefix) cmp := bytes.Compare(s.nextK, s.toPrefix)
return (s.orderAscend && cmp < 0) || (!s.orderAscend && cmp > 0) return (s.orderAscend && cmp < 0) || (!s.orderAscend && cmp > 0)
} }
func (s *cursor2stream) Next() ([]byte, []byte, error) { func (s *cursor2stream) Next() (k, v []byte, err error) {
select { select {
case <-s.ctx.Done(): case <-s.ctx.Done():
return nil, nil, s.ctx.Err() return nil, nil, s.ctx.Err()
default: default:
} }
s.limit-- s.limit--
k, v, err := s.nextK, s.nextV, s.nextErr k, v, err = s.nextK, s.nextV, s.nextErr
if s.orderAscend { if s.orderAscend {
s.nextK, s.nextV, s.nextErr = s.c.Next() s.nextK, s.nextV, s.nextErr = s.c.Next()
} else { } else {