From 9f377cde12e3265c25429c6843ce230f1039982e Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Mon, 12 Jul 2021 14:14:14 +0300 Subject: [PATCH] storage: convert key once in `MemoryStore.seek` There is no need in additional allocations. Signed-off-by: Evgeniy Stratonikov --- pkg/core/storage/memory_store.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/core/storage/memory_store.go b/pkg/core/storage/memory_store.go index 3d542dd82..0d3e9eae2 100644 --- a/pkg/core/storage/memory_store.go +++ b/pkg/core/storage/memory_store.go @@ -121,8 +121,9 @@ func (s *MemoryStore) SeekAll(key []byte, f func(k, v []byte)) { // seek is an internal unlocked implementation of Seek. func (s *MemoryStore) seek(key []byte, f func(k, v []byte)) { + sk := string(key) for k, v := range s.mem { - if strings.HasPrefix(k, string(key)) { + if strings.HasPrefix(k, sk) { f([]byte(k), v) } }