[#1262] metabase: Remove list index in place Delete
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
43867a3093
commit
de5a2f6574
1 changed files with 5 additions and 5 deletions
|
@ -200,16 +200,16 @@ func delListIndexItem(tx *bbolt.Tx, item namedBucketItem) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove element from the list
|
// remove element from the list
|
||||||
newLst := make([][]byte, 0, len(lst))
|
|
||||||
|
|
||||||
for i := range lst {
|
for i := range lst {
|
||||||
if !bytes.Equal(item.val, lst[i]) {
|
if bytes.Equal(item.val, lst[i]) {
|
||||||
newLst = append(newLst, lst[i])
|
copy(lst[i:], lst[i+1:])
|
||||||
|
lst = lst[:len(lst)-1]
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if list empty, remove the key from <list> bucket
|
// if list empty, remove the key from <list> bucket
|
||||||
if len(newLst) == 0 {
|
if len(lst) == 0 {
|
||||||
_ = bkt.Delete(item.key) // ignore error, best effort there
|
_ = bkt.Delete(item.key) // ignore error, best effort there
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue