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 {
it := txn.NewIterator(badger.DefaultIteratorOptions)
defer it.Close()
// avoid allocations by reusing the value buffer
var value []byte
// loop through every key-value-pair and call the function
for it.Rewind(); it.Valid(); it.Next() {
item := it.Item()
var err error
value, err = item.ValueCopy(value)
value, err := item.ValueCopy(nil)
if err != nil {
return err
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment