From 5bfc54974669bfddf1e9693d9625578a8167778f Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 30 Jun 2022 11:58:51 +0300 Subject: [PATCH] [#564] neofs: Merge `if` with same condition in `CreateContainer` Signed-off-by: Leonard Lyubich --- api/layer/neofs_mock.go | 11 ++++------- internal/neofs/neofs.go | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/api/layer/neofs_mock.go b/api/layer/neofs_mock.go index 2cead060..6a02437a 100644 --- a/api/layer/neofs_mock.go +++ b/api/layer/neofs_mock.go @@ -71,6 +71,10 @@ func (t *TestNeoFS) CreateContainer(_ context.Context, prm PrmContainerCreate) ( container.SetCreationTime(&cnr, time.Now()) if prm.Name != "" { + var d container.Domain + d.SetName(prm.Name) + + container.WriteDomain(&cnr, d) container.SetName(&cnr, prm.Name) } @@ -78,13 +82,6 @@ func (t *TestNeoFS) CreateContainer(_ context.Context, prm PrmContainerCreate) ( cnr.SetAttribute(prm.AdditionalAttributes[i][0], prm.AdditionalAttributes[i][1]) } - if prm.Name != "" { - var d container.Domain - d.SetName(prm.Name) - - container.WriteDomain(&cnr, d) - } - b := make([]byte, 32) if _, err := io.ReadFull(rand.Reader, b); err != nil { return nil, err diff --git a/internal/neofs/neofs.go b/internal/neofs/neofs.go index 26ed527c..dffa0ebd 100644 --- a/internal/neofs/neofs.go +++ b/internal/neofs/neofs.go @@ -120,6 +120,10 @@ func (x *NeoFS) CreateContainer(ctx context.Context, prm layer.PrmContainerCreat container.SetCreationTime(&cnr, time.Now()) if prm.Name != "" { + var d container.Domain + d.SetName(prm.Name) + + container.WriteDomain(&cnr, d) container.SetName(&cnr, prm.Name) } @@ -136,13 +140,6 @@ func (x *NeoFS) CreateContainer(ctx context.Context, prm layer.PrmContainerCreat container.DisableHomomorphicHashing(&cnr) } - if prm.Name != "" { - var d container.Domain - d.SetName(prm.Name) - - container.WriteDomain(&cnr, d) - } - var prmPut pool.PrmContainerPut prmPut.SetContainer(cnr) prmPut.SetWaitParams(x.await)