diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-09 12:37:07 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-09 12:37:07 -0600 |
commit | 511ecba69baedae05a64007e7b86fa6bc6d3b209 (patch) | |
tree | 944aebf41c807fe7c6aedcd3cd997fb24acf56e3 /cursor.go | |
parent | Add seek forward test. (diff) | |
download | dedo-511ecba69baedae05a64007e7b86fa6bc6d3b209.tar.gz dedo-511ecba69baedae05a64007e7b86fa6bc6d3b209.tar.xz |
Refactor Cursor.Next() to use Cursor.next().
Diffstat (limited to 'cursor.go')
-rw-r--r-- | cursor.go | 24 |
1 files changed, 1 insertions, 23 deletions
@@ -55,29 +55,7 @@ func (c *Cursor) Last() (key []byte, value []byte) { // If the cursor is at the end of the bucket then a nil key and value are returned. func (c *Cursor) Next() (key []byte, value []byte) { _assert(c.bucket.tx.db != nil, "tx closed") - - // Attempt to move over one element until we're successful. - // Move up the stack as we hit the end of each page in our stack. - var i int - for i = len(c.stack) - 1; i >= 0; i-- { - elem := &c.stack[i] - if elem.index < elem.count()-1 { - elem.index++ - break - } - } - - // If we've hit the root page then stop and return. This will leave the - // cursor on this last page. - if i == -1 { - return nil, nil - } - - // Otherwise start from where we left off in the stack and find the - // first element of the first leaf page. - c.stack = c.stack[:i+1] - c.first() - k, v, flags := c.keyValue() + k, v, flags := c.next() if (flags & uint32(bucketLeafFlag)) != 0 { return k, nil } |