[#1386] eacl/v2: Allocate []eaclSDK.Header slice immediately
There is no point in having intermediate `[]sessionSDK.XHeader`. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
b24589b62d
commit
915f87959e
2 changed files with 10 additions and 17 deletions
|
@ -14,7 +14,6 @@ import (
|
||||||
objectSDKAddress "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
objectSDKAddress "github.com/nspcc-dev/neofs-sdk-go/object/address"
|
||||||
objectSDKID "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
objectSDKID "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||||
sessionSDK "github.com/nspcc-dev/neofs-sdk-go/session"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Option func(*cfg)
|
type Option func(*cfg)
|
||||||
|
@ -84,15 +83,7 @@ func (h headerSource) HeadersOfType(typ eaclSDK.FilterHeaderType) ([]eaclSDK.Hea
|
||||||
}
|
}
|
||||||
|
|
||||||
func requestHeaders(msg xHeaderSource) []eaclSDK.Header {
|
func requestHeaders(msg xHeaderSource) []eaclSDK.Header {
|
||||||
xHdrs := msg.GetXHeaders()
|
return msg.GetXHeaders()
|
||||||
|
|
||||||
res := make([]eaclSDK.Header, 0, len(xHdrs))
|
|
||||||
|
|
||||||
for i := range xHdrs {
|
|
||||||
res = append(res, sessionSDK.NewXHeaderFromV2(&xHdrs[i]))
|
|
||||||
}
|
|
||||||
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *cfg) objectHeaders() ([]eaclSDK.Header, error) {
|
func (h *cfg) objectHeaders() ([]eaclSDK.Header, error) {
|
||||||
|
|
|
@ -2,10 +2,12 @@ package v2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||||
|
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
|
||||||
|
sessionSDK "github.com/nspcc-dev/neofs-sdk-go/session"
|
||||||
)
|
)
|
||||||
|
|
||||||
type xHeaderSource interface {
|
type xHeaderSource interface {
|
||||||
GetXHeaders() []session.XHeader
|
GetXHeaders() []eaclSDK.Header
|
||||||
}
|
}
|
||||||
|
|
||||||
type requestXHeaderSource struct {
|
type requestXHeaderSource struct {
|
||||||
|
@ -18,7 +20,7 @@ type responseXHeaderSource struct {
|
||||||
req Request
|
req Request
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s requestXHeaderSource) GetXHeaders() []session.XHeader {
|
func (s requestXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
||||||
ln := 0
|
ln := 0
|
||||||
xHdrs := make([][]session.XHeader, 0)
|
xHdrs := make([][]session.XHeader, 0)
|
||||||
|
|
||||||
|
@ -30,18 +32,18 @@ func (s requestXHeaderSource) GetXHeaders() []session.XHeader {
|
||||||
xHdrs = append(xHdrs, x)
|
xHdrs = append(xHdrs, x)
|
||||||
}
|
}
|
||||||
|
|
||||||
res := make([]session.XHeader, 0, ln)
|
res := make([]eaclSDK.Header, 0, ln)
|
||||||
|
|
||||||
for i := range xHdrs {
|
for i := range xHdrs {
|
||||||
for j := range xHdrs[i] {
|
for j := range xHdrs[i] {
|
||||||
res = append(res, xHdrs[i][j])
|
res = append(res, sessionSDK.NewXHeaderFromV2(&xHdrs[i][j]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s responseXHeaderSource) GetXHeaders() []session.XHeader {
|
func (s responseXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
||||||
ln := 0
|
ln := 0
|
||||||
xHdrs := make([][]session.XHeader, 0)
|
xHdrs := make([][]session.XHeader, 0)
|
||||||
|
|
||||||
|
@ -53,11 +55,11 @@ func (s responseXHeaderSource) GetXHeaders() []session.XHeader {
|
||||||
xHdrs = append(xHdrs, x)
|
xHdrs = append(xHdrs, x)
|
||||||
}
|
}
|
||||||
|
|
||||||
res := make([]session.XHeader, 0, ln)
|
res := make([]eaclSDK.Header, 0, ln)
|
||||||
|
|
||||||
for i := range xHdrs {
|
for i := range xHdrs {
|
||||||
for j := range xHdrs[i] {
|
for j := range xHdrs[i] {
|
||||||
res = append(res, xHdrs[i][j])
|
res = append(res, sessionSDK.NewXHeaderFromV2(&xHdrs[i][j]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue