Skip to content
Snippets Groups Projects
Commit 5f0bbc63 authored by Wolfgang Welz's avatar Wolfgang Welz
Browse files

Do not reuse the value buffer when iterating through the database

parent 5a72ab68
No related branches found
No related tags found
No related merge requests found
...@@ -129,15 +129,11 @@ func (this *databaseImpl) ForEach(consumer func([]byte, []byte)) error { ...@@ -129,15 +129,11 @@ func (this *databaseImpl) ForEach(consumer func([]byte, []byte)) error {
it := txn.NewIterator(badger.DefaultIteratorOptions) it := txn.NewIterator(badger.DefaultIteratorOptions)
defer it.Close() defer it.Close()
// avoid allocations by reusing the value buffer
var value []byte
// loop through every key-value-pair and call the function // loop through every key-value-pair and call the function
for it.Rewind(); it.Valid(); it.Next() { for it.Rewind(); it.Valid(); it.Next() {
item := it.Item() item := it.Item()
var err error value, err := item.ValueCopy(nil)
value, err = item.ValueCopy(value)
if err != nil { if err != nil {
return err return err
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment