From 5f0bbc634a2e506108a53464a3df566247a8b572 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz <welzwo@gmail.com> Date: Mon, 17 Jun 2019 17:46:13 +0200 Subject: [PATCH] Do not reuse the value buffer when iterating through the database --- packages/database/database.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/database/database.go b/packages/database/database.go index 06899925..59a994b6 100644 --- a/packages/database/database.go +++ b/packages/database/database.go @@ -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 } -- GitLab