diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-28 15:13:00 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-02-28 15:13:07 -0700 |
commit | 956453b69fd8ba9a356edcf81597d90d769311b2 (patch) | |
tree | e6767873d45061d0ca2f4c3f35b235febe2b922e /cursor.go | |
parent | Add bucket reclamation. (diff) | |
download | dedo-956453b69fd8ba9a356edcf81597d90d769311b2.tar.gz dedo-956453b69fd8ba9a356edcf81597d90d769311b2.tar.xz |
Minor refactor.
Diffstat (limited to 'cursor.go')
-rw-r--r-- | cursor.go | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -16,9 +16,7 @@ type Cursor struct { // First moves the cursor to the first item in the bucket and returns its key and value. // If the bucket is empty then a nil key and value are returned. func (c *Cursor) First() (key []byte, value []byte) { - if len(c.stack) > 0 { - c.stack = c.stack[:0] - } + c.stack = c.stack[:0] p := c.transaction.page(c.root) c.stack = append(c.stack, pageElementRef{page: p, index: 0}) c.first() @@ -28,9 +26,7 @@ func (c *Cursor) First() (key []byte, value []byte) { // Last moves the cursor to the last item in the bucket and returns its key and value. // If the bucket is empty then a nil key and value are returned. func (c *Cursor) Last() (key []byte, value []byte) { - if len(c.stack) > 0 { - c.stack = c.stack[:0] - } + c.stack = c.stack[:0] p := c.transaction.page(c.root) c.stack = append(c.stack, pageElementRef{page: p, index: p.count - 1}) c.last() |