storage: convert key once in MemoryStore.seek

There is no need in additional allocations.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgeniy Stratonikov 2021-07-12 14:14:14 +03:00
parent 1853d0c713
commit 9f377cde12

View file

@ -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)
}
}