From 13e74fce8a993e496067c07357cbc19c5bc1941a Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 17 Jun 2022 01:00:38 +0300 Subject: [PATCH] [#1513] ir/settlement: Do not allocate intermediate slice of nodes After recent changes `buildContainer` method returns two-dimensional slice of `NodeInfo` so there is no need to flatten it to build slice of `common.NodeInfo`. Signed-off-by: Leonard Lyubich --- pkg/innerring/settlement.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pkg/innerring/settlement.go b/pkg/innerring/settlement.go index dbb6a8503..0a0033daa 100644 --- a/pkg/innerring/settlement.go +++ b/pkg/innerring/settlement.go @@ -19,7 +19,6 @@ import ( auditClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit" balanceClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance" containerClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" - "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/util/logger" auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit" containerAPI "github.com/nspcc-dev/neofs-sdk-go/container" @@ -173,13 +172,20 @@ func (s settlementDeps) ContainerNodes(e uint64, cid cid.ID) ([]common.NodeInfo, return nil, err } - ns := placement.FlattenNodes(cn) - res := make([]common.NodeInfo, 0, len(ns)) + var sz int - for i := range ns { - res = append(res, &nodeInfoWrapper{ - ni: ns[i], - }) + for i := range cn { + sz += len(cn[i]) + } + + res := make([]common.NodeInfo, 0, sz) + + for i := range cn { + for j := range cn[i] { + res = append(res, nodeInfoWrapper{ + ni: cn[i][j], + }) + } } return res, nil