diff --git a/pkg/morph/event/notary_preparator.go b/pkg/morph/event/notary_preparator.go index 7a2dcafee7..f27d3404a5 100644 --- a/pkg/morph/event/notary_preparator.go +++ b/pkg/morph/event/notary_preparator.go @@ -5,6 +5,7 @@ import ( "encoding/binary" "errors" "fmt" + "slices" "sync" lru "github.com/hashicorp/golang-lru/v2" @@ -85,7 +86,7 @@ func notaryPreparator(localAcc util.Uint160, alphaKeys client.AlphabetKeys, bc B contractSysCall := make([]byte, 4) binary.LittleEndian.PutUint32(contractSysCall, interopnames.ToID([]byte(interopnames.SystemContractCall))) - dummyInvocationScript := append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...) + dummyInvocationScript := slices.Concat([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)) const txCacheSize = 1000 cache, _ := lru.New[util.Uint256, struct{}](txCacheSize) diff --git a/pkg/services/object/put/distributed.go b/pkg/services/object/put/distributed.go index 9b2f7726f0..cb0b59554f 100644 --- a/pkg/services/object/put/distributed.go +++ b/pkg/services/object/put/distributed.go @@ -189,14 +189,7 @@ func (x placementIterator) iterateNodesForObject(obj oid.ID, f func(nodeDesc) er return fmt.Errorf("sort container nodes for the object: %w", err) } if x.linearReplNum > 0 { - var n int - for i := range nodeLists { - n += len(nodeLists[i]) - } - ns := make([]netmap.NodeInfo, 0, n) - for i := range nodeLists { - ns = append(ns, nodeLists[i]...) - } + ns := slices.Concat(nodeLists...) nodeLists = [][]netmap.NodeInfo{ns} replCounts = []uint{x.linearReplNum} } else { diff --git a/pkg/services/object_manager/placement/netmap.go b/pkg/services/object_manager/placement/netmap.go index c5013ddd0b..6e275ed985 100644 --- a/pkg/services/object_manager/placement/netmap.go +++ b/pkg/services/object_manager/placement/netmap.go @@ -3,6 +3,7 @@ package placement import ( "crypto/sha256" "fmt" + "slices" "sync" "github.com/hashicorp/golang-lru/v2/simplelru" @@ -99,17 +100,5 @@ func BuildObjectPlacement(nm *netmapSDK.NetMap, cnrNodes [][]netmapSDK.NodeInfo, // FlattenNodes appends each row to the flat list. func FlattenNodes(ns [][]netmapSDK.NodeInfo) []netmapSDK.NodeInfo { - var sz int - - for i := range ns { - sz += len(ns[i]) - } - - result := make([]netmapSDK.NodeInfo, 0, sz) - - for i := range ns { - result = append(result, ns[i]...) - } - - return result + return slices.Concat(ns...) } diff --git a/pkg/services/object_manager/placement/traverser.go b/pkg/services/object_manager/placement/traverser.go index 07ce073598..6fca550931 100644 --- a/pkg/services/object_manager/placement/traverser.go +++ b/pkg/services/object_manager/placement/traverser.go @@ -3,6 +3,7 @@ package placement import ( "errors" "fmt" + "slices" "sync" "github.com/nspcc-dev/neofs-node/pkg/network" @@ -119,17 +120,7 @@ func NewTraverser(opts ...Option) (*Traverser, error) { } func flatNodes(ns [][]netmap.NodeInfo) [][]netmap.NodeInfo { - sz := 0 - for i := range ns { - sz += len(ns[i]) - } - - flat := make([]netmap.NodeInfo, 0, sz) - for i := range ns { - flat = append(flat, ns[i]...) - } - - return [][]netmap.NodeInfo{flat} + return [][]netmap.NodeInfo{slices.Concat(ns...)} } // Node is a descriptor of storage node with information required for intra-container communication. diff --git a/pkg/services/tree/sync.go b/pkg/services/tree/sync.go index 9249c2bb00..ef7cb5a8d0 100644 --- a/pkg/services/tree/sync.go +++ b/pkg/services/tree/sync.go @@ -8,6 +8,7 @@ import ( "io" "math" "math/rand" + "slices" "sync" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/pilorama" @@ -365,10 +366,7 @@ func randomizeNodeOrder(cnrNodes []netmap.NodeInfo, pos int) []netmap.NodeInfo { return nil } - nodes := make([]netmap.NodeInfo, len(cnrNodes)-1) - n := copy(nodes, cnrNodes[:pos]) - copy(nodes[n:], cnrNodes[pos+1:]) - + nodes := slices.Concat(cnrNodes[:pos], cnrNodes[pos+1:]) rand.Shuffle(len(nodes), func(i, j int) { nodes[i], nodes[j] = nodes[j], nodes[i] })