forked from TrueCloudLab/frostfs-node
[#1386] eacl/v2: Do not allocate intermediate slices for XHeaders
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
915f87959e
commit
63cdc16088
1 changed files with 10 additions and 21 deletions
|
@ -1,7 +1,6 @@
|
||||||
package v2
|
package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
|
||||||
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||||
sessionSDK "github.com/nspcc-dev/neofs-sdk-go/session"
|
sessionSDK "github.com/nspcc-dev/neofs-sdk-go/session"
|
||||||
)
|
)
|
||||||
|
@ -22,21 +21,16 @@ type responseXHeaderSource struct {
|
||||||
|
|
||||||
func (s requestXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
func (s requestXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
||||||
ln := 0
|
ln := 0
|
||||||
xHdrs := make([][]session.XHeader, 0)
|
|
||||||
|
|
||||||
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
||||||
x := meta.GetXHeaders()
|
ln += len(meta.GetXHeaders())
|
||||||
|
|
||||||
ln += len(x)
|
|
||||||
|
|
||||||
xHdrs = append(xHdrs, x)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res := make([]eaclSDK.Header, 0, ln)
|
res := make([]eaclSDK.Header, 0, ln)
|
||||||
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
||||||
for i := range xHdrs {
|
x := meta.GetXHeaders()
|
||||||
for j := range xHdrs[i] {
|
for i := range x {
|
||||||
res = append(res, sessionSDK.NewXHeaderFromV2(&xHdrs[i][j]))
|
res = append(res, sessionSDK.NewXHeaderFromV2(&x[i]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,21 +39,16 @@ func (s requestXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
||||||
|
|
||||||
func (s responseXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
func (s responseXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
||||||
ln := 0
|
ln := 0
|
||||||
xHdrs := make([][]session.XHeader, 0)
|
|
||||||
|
|
||||||
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
||||||
x := meta.GetXHeaders()
|
ln += len(meta.GetXHeaders())
|
||||||
|
|
||||||
ln += len(x)
|
|
||||||
|
|
||||||
xHdrs = append(xHdrs, x)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res := make([]eaclSDK.Header, 0, ln)
|
res := make([]eaclSDK.Header, 0, ln)
|
||||||
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
||||||
for i := range xHdrs {
|
x := meta.GetXHeaders()
|
||||||
for j := range xHdrs[i] {
|
for i := range x {
|
||||||
res = append(res, sessionSDK.NewXHeaderFromV2(&xHdrs[i][j]))
|
res = append(res, sessionSDK.NewXHeaderFromV2(&x[i]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue