diff --git a/client/common.go b/client/common.go index 56de0a30..759606ee 100644 --- a/client/common.go +++ b/client/common.go @@ -71,14 +71,11 @@ func (x *prmCommonMeta) WithXHeaders(hs ...string) { func (x prmCommonMeta) writeToMetaHeader(h *v2session.RequestMetaHeader) { if len(x.xHeaders) > 0 { - hs := make([]*v2session.XHeader, 0, len(x.xHeaders)/2) + hs := make([]v2session.XHeader, len(x.xHeaders)/2) for i := 0; i < len(x.xHeaders); i += 2 { - var h v2session.XHeader - h.SetKey(x.xHeaders[i]) - h.SetValue(x.xHeaders[i+1]) - - hs = append(hs, &h) + hs[i].SetKey(x.xHeaders[i]) + hs[i].SetValue(x.xHeaders[i+1]) } h.SetXHeaders(hs) diff --git a/client/container.go b/client/container.go index 2cea90bd..d86dd544 100644 --- a/client/container.go +++ b/client/container.go @@ -255,17 +255,17 @@ func (x *PrmContainerList) SetAccount(id owner.ID) { type ResContainerList struct { statusRes - ids []*cid.ID + ids []cid.ID } // Containers returns list of identifiers of the account-owned containers. // // Client doesn't retain value so modification is safe. -func (x ResContainerList) Containers() []*cid.ID { +func (x ResContainerList) Containers() []cid.ID { return x.ids } -func (x *ResContainerList) setContainers(ids []*cid.ID) { +func (x *ResContainerList) setContainers(ids []cid.ID) { x.ids = ids } @@ -319,10 +319,10 @@ func (c *Client) ContainerList(ctx context.Context, prm PrmContainerList) (*ResC cc.result = func(r responseV2) { resp := r.(*v2container.ListResponse) - ids := make([]*cid.ID, 0, len(resp.GetBody().GetContainerIDs())) + ids := make([]cid.ID, len(resp.GetBody().GetContainerIDs())) - for _, cidV2 := range resp.GetBody().GetContainerIDs() { - ids = append(ids, cid.NewFromV2(cidV2)) + for i, cidV2 := range resp.GetBody().GetContainerIDs() { + ids[i] = *cid.NewFromV2(&cidV2) } res.setContainers(ids) @@ -695,9 +695,9 @@ func (c *Client) ContainerAnnounceUsedSpace(ctx context.Context, prm PrmAnnounce } // convert list of SDK announcement structures into NeoFS-API v2 list - v2announce := make([]*v2container.UsedSpaceAnnouncement, 0, len(prm.announcements)) + v2announce := make([]v2container.UsedSpaceAnnouncement, len(prm.announcements)) for i := range prm.announcements { - v2announce = append(v2announce, prm.announcements[i].ToV2()) + v2announce[i] = *prm.announcements[i].ToV2() } // prepare body of the NeoFS-API v2 request and request itself diff --git a/client/object_hash.go b/client/object_hash.go index 44b187c1..a0d5b9c4 100644 --- a/client/object_hash.go +++ b/client/object_hash.go @@ -71,10 +71,9 @@ func (x *PrmObjectHash) SetRangeList(r ...uint64) { panic("odd number of range parameters") } - rs := make([]*v2object.Range, ln/2) + rs := make([]v2object.Range, ln/2) for i := 0; i < ln/2; i++ { - rs[i] = new(v2object.Range) rs[i].SetOffset(r[2*i]) rs[i].SetLength(r[2*i+1]) } diff --git a/client/object_search.go b/client/object_search.go index 7e93ccf9..38f63994 100644 --- a/client/object_search.go +++ b/client/object_search.go @@ -95,7 +95,7 @@ type ObjectListReader struct { // initially bound to contextCall bodyResp v2object.SearchResponseBody - tail []*v2refs.ObjectID + tail []v2refs.ObjectID } // UseKey specifies private key to sign the requests. @@ -130,7 +130,7 @@ func (x *ObjectListReader) Read(buf []oid.ID) (int, bool) { } for i := 0; i < read; i++ { - buf[i] = *oid.NewIDFromV2(x.tail[i]) // need smth better + buf[i] = *oid.NewIDFromV2(&x.tail[i]) // need smth better } x.tail = x.tail[read:] @@ -140,7 +140,7 @@ func (x *ObjectListReader) Read(buf []oid.ID) (int, bool) { } var ok bool - var ids []*v2refs.ObjectID + var ids []v2refs.ObjectID var i, ln, rem int for { @@ -164,7 +164,7 @@ func (x *ObjectListReader) Read(buf []oid.ID) (int, bool) { } for i = 0; i < ln; i++ { - buf[read+i] = *oid.NewIDFromV2(ids[i]) // need smth better + buf[read+i] = *oid.NewIDFromV2(&ids[i]) // need smth better } read += ln diff --git a/client/object_search_test.go b/client/object_search_test.go index 3ce52c15..7809729c 100644 --- a/client/object_search_test.go +++ b/client/object_search_test.go @@ -175,9 +175,9 @@ func testListReaderResponse(t *testing.T) (*ObjectListReader, func(id []oid.ID) resp := new(object.SearchResponse) resp.SetBody(new(object.SearchResponseBody)) - v2id := make([]*refs.ObjectID, len(id)) + v2id := make([]refs.ObjectID, len(id)) for i := range id { - v2id[i] = id[i].ToV2() + v2id[i] = *id[i].ToV2() } resp.GetBody().SetIDList(v2id) err := signatureV2.SignServiceMessage(&p.PrivateKey, resp) diff --git a/client/reputation.go b/client/reputation.go index a1b4b46d..c6806a59 100644 --- a/client/reputation.go +++ b/client/reputation.go @@ -65,11 +65,8 @@ func (c *Client) AnnounceLocalTrust(ctx context.Context, prm PrmAnnounceLocalTru reqBody := new(v2reputation.AnnounceLocalTrustRequestBody) reqBody.SetEpoch(prm.epoch) - trusts := make([]*reputation.Trust, 0, len(prm.trusts)) - - for i := range prm.trusts { - trusts = append(trusts, &prm.trusts[i]) - } + trusts := make([]reputation.Trust, len(prm.trusts)) + copy(trusts, prm.trusts) reqBody.SetTrusts(reputation.TrustsToV2(trusts)) diff --git a/client/status/common.go b/client/status/common.go index e5051c0a..05c5ae28 100644 --- a/client/status/common.go +++ b/client/status/common.go @@ -99,7 +99,7 @@ func (x *WrongMagicNumber) WriteCorrectMagic(magic uint64) { d.SetValue(buf) // attach the detail - x.v2.AppendDetails(&d) + x.v2.AppendDetails(d) } // CorrectMagic returns network magic returned by the server.