Skip to content

Commit

Permalink
changes in pebbleDBIterator Value() impl:
Browse files Browse the repository at this point in the history
- returns the value itself, not a copy
- updated docs to reflect the change
  • Loading branch information
alesforz committed Jul 11, 2024
1 parent 709efff commit 8e8fc69
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,18 @@ func (itr *pebbleDBIterator) Valid() bool {

// Key implements Iterator.
// The caller should not modify the contents of the returned slice.
// To work with the slice, make a copy and modify the copy instead.
// Instead, the caller should make a copy and work on the copy.
func (itr *pebbleDBIterator) Key() []byte {
itr.assertIsValid()
return itr.source.Key()
}

// Value implements Iterator.
// The caller should not modify the contents of the returned slice.
// Instead, the caller should make a copy and work on the copy.
func (itr *pebbleDBIterator) Value() []byte {
// Value returns a copy of the current value.
// See https://github.com/cockroachdb/pebble/blob/v1.0.0/iterator.go#L2116
itr.assertIsValid()
return cp(itr.source.Value())
return itr.source.Value()
}

// Next implements Iterator.
Expand Down

0 comments on commit 8e8fc69

Please sign in to comment.