forked from TrueCloudLab/frostfs-node
[#1671] Use slices.Delete()
where possible
gopatch is missing for this one, because https://github.com/uber-go/gopatch/issues/179 Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
155d3ddb6e
commit
460e5cbccf
7 changed files with 15 additions and 8 deletions
|
@ -1,6 +1,8 @@
|
|||
package tui
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
@ -26,7 +28,7 @@ func (f *InputFieldWithHistory) AddToHistory(s string) {
|
|||
|
||||
// Used history data for search prompt, so just make that data recent.
|
||||
if f.historyPointer != len(f.history) && s == f.history[f.historyPointer] {
|
||||
f.history = append(f.history[:f.historyPointer], f.history[f.historyPointer+1:]...)
|
||||
f.history = slices.Delete(f.history, f.historyPointer, f.historyPointer+1)
|
||||
f.history = append(f.history, s)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package blobstortest
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||
|
@ -26,7 +27,7 @@ func TestIterate(t *testing.T, cons Constructor, minSize, maxSize uint64) {
|
|||
_, err := s.Delete(context.Background(), delPrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
objects = append(objects[:delID], objects[delID+1:]...)
|
||||
objects = slices.Delete(objects, delID, delID+1)
|
||||
|
||||
runTestNormalHandler(t, s, objects)
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr"
|
||||
|
@ -250,7 +251,7 @@ func freePotentialLocks(tx *bbolt.Tx, idCnr cid.ID, locker oid.ID) ([]oid.Addres
|
|||
unlockedObjects = append(unlockedObjects, addr)
|
||||
} else {
|
||||
// exclude locker
|
||||
keyLockers = append(keyLockers[:i], keyLockers[i+1:]...)
|
||||
keyLockers = slices.Delete(keyLockers, i, i+1)
|
||||
|
||||
v, err = encodeList(keyLockers)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strconv"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
|
@ -182,7 +183,7 @@ func (exec *execCtx) addMembers(incoming []oid.ID) {
|
|||
for i := range members {
|
||||
for j := 0; j < len(incoming); j++ { // don't use range, slice mutates in body
|
||||
if members[i].Equals(incoming[j]) {
|
||||
incoming = append(incoming[:j], incoming[j+1:]...)
|
||||
incoming = slices.Delete(incoming, j, j+1)
|
||||
j--
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package searchsvc
|
|||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"sync"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
|
||||
|
@ -53,7 +54,7 @@ func (w *uniqueIDWriter) WriteIDs(list []oid.ID) error {
|
|||
}
|
||||
|
||||
// exclude processed address
|
||||
list = append(list[:i], list[i+1:]...)
|
||||
list = slices.Delete(list, i, i+1)
|
||||
i--
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package util
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
|
||||
|
@ -93,7 +94,7 @@ func (p *remotePlacement) BuildPlacement(ctx context.Context, cnr cid.ID, obj *o
|
|||
}
|
||||
|
||||
if p.netmapKeys.IsLocalKey(vs[i][j].PublicKey()) {
|
||||
vs[i] = append(vs[i][:j], vs[i][j+1:]...)
|
||||
vs[i] = slices.Delete(vs[i], j, j+1)
|
||||
j--
|
||||
}
|
||||
}
|
||||
|
|
|
@ -288,8 +288,8 @@ func (t *Traverser) Next() []Node {
|
|||
func (t *Traverser) skipEmptyVectors() {
|
||||
for i := 0; i < len(t.vectors); i++ { // don't use range, slice changes in body
|
||||
if len(t.vectors[i]) == 0 && t.rem[i] <= 0 || t.rem[0] == 0 {
|
||||
t.vectors = append(t.vectors[:i], t.vectors[i+1:]...)
|
||||
t.rem = append(t.rem[:i], t.rem[i+1:]...)
|
||||
t.vectors = slices.Delete(t.vectors, i, i+1)
|
||||
t.rem = slices.Delete(t.rem, i, i+1)
|
||||
i--
|
||||
} else {
|
||||
break
|
||||
|
|
Loading…
Add table
Reference in a new issue