[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-06-17 01:00:38 +03:00 committed by LeL
parent c408a6a0db
commit 13e74fce8a

View file

@ -19,7 +19,6 @@ import (
auditClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit" auditClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit"
balanceClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance" balanceClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
containerClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" 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" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit" auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit"
containerAPI "github.com/nspcc-dev/neofs-sdk-go/container" containerAPI "github.com/nspcc-dev/neofs-sdk-go/container"
@ -173,14 +172,21 @@ func (s settlementDeps) ContainerNodes(e uint64, cid cid.ID) ([]common.NodeInfo,
return nil, err return nil, err
} }
ns := placement.FlattenNodes(cn) var sz int
res := make([]common.NodeInfo, 0, len(ns))
for i := range ns { for i := range cn {
res = append(res, &nodeInfoWrapper{ sz += len(cn[i])
ni: ns[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 return res, nil
} }