Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cursor: remove redundant check when seek #75

Merged
merged 1 commit into from
Mar 17, 2018
Merged

Conversation

BlueBlue-Lee
Copy link
Contributor

@BlueBlue-Lee BlueBlue-Lee commented Jan 20, 2018

It will be checked in Cursor.keyValue func.

func (c *Cursor) keyValue() ([]byte, []byte, uint32) {
	ref := &c.stack[len(c.stack)-1]
	if ref.count() == 0 || ref.index >= ref.count() {
		return nil, nil, 0
	}

	// Retrieve value from node.
	if ref.node != nil {
		inode := &ref.node.inodes[ref.index]
		return inode.key, inode.value, inode.flags
	}

	// Or retrieve value from page.
	elem := ref.page.leafPageElement(uint16(ref.index))
	return elem.key(), elem.value(), elem.flags
}

@codecov-io
Copy link

codecov-io commented Jan 20, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@d57ee90). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #75   +/-   ##
=========================================
  Coverage          ?   85.56%           
=========================================
  Files             ?        9           
  Lines             ?     1856           
  Branches          ?        0           
=========================================
  Hits              ?     1588           
  Misses            ?      158           
  Partials          ?      110
Impacted Files Coverage Δ
cursor.go 95.28% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d57ee90...ebb8629. Read the comment docs.

Copy link
Contributor

@heyitsanthony heyitsanthony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch, lgtm

@@ -157,12 +157,6 @@ func (c *Cursor) seek(seek []byte) (key []byte, value []byte, flags uint32) {
// Start from root page/node and traverse to correct page.
c.stack = c.stack[:0]
c.search(seek, c.bucket.root)
ref := &c.stack[len(c.stack)-1]

// If the cursor is pointing to the end of page/node then return nil.
Copy link
Contributor

@heyitsanthony heyitsanthony Mar 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this comment down to the keyValue code that does the check so the explanation isn't lost?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants