From de5a2f6574a8de1dcac5976132e13e823cd7c249 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 21 Mar 2022 18:39:46 +0300 Subject: [PATCH] [#1262] metabase: Remove list index in place `Delete` Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/metabase/delete.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/local_object_storage/metabase/delete.go b/pkg/local_object_storage/metabase/delete.go index 29905a8472..c5b89e2adc 100644 --- a/pkg/local_object_storage/metabase/delete.go +++ b/pkg/local_object_storage/metabase/delete.go @@ -200,16 +200,16 @@ func delListIndexItem(tx *bbolt.Tx, item namedBucketItem) error { } // remove element from the list - newLst := make([][]byte, 0, len(lst)) - for i := range lst { - if !bytes.Equal(item.val, lst[i]) { - newLst = append(newLst, lst[i]) + if bytes.Equal(item.val, lst[i]) { + copy(lst[i:], lst[i+1:]) + lst = lst[:len(lst)-1] + break } } // if list empty, remove the key from bucket - if len(newLst) == 0 { + if len(lst) == 0 { _ = bkt.Delete(item.key) // ignore error, best effort there return nil