forked from TrueCloudLab/frostfs-node
[#1094] eacl/v2: preallocate slice in headersFromObject
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
3407fef799
commit
1bdbd6ed22
1 changed files with 6 additions and 7 deletions
|
@ -40,9 +40,12 @@ func u64Value(v uint64) string {
|
|||
}
|
||||
|
||||
func headersFromObject(obj *object.Object, addr *objectSDK.Address) []eaclSDK.Header {
|
||||
// TODO: optimize allocs
|
||||
res := make([]eaclSDK.Header, 0)
|
||||
var count int
|
||||
for obj := obj; obj != nil; obj = obj.GetParent() {
|
||||
count += 9 + len(obj.Attributes())
|
||||
}
|
||||
|
||||
res := make([]eaclSDK.Header, 0, count)
|
||||
for ; obj != nil; obj = obj.GetParent() {
|
||||
res = append(res,
|
||||
cidHeader(addr.ContainerID()),
|
||||
|
@ -85,13 +88,9 @@ func headersFromObject(obj *object.Object, addr *objectSDK.Address) []eaclSDK.He
|
|||
)
|
||||
|
||||
attrs := obj.Attributes()
|
||||
hs := make([]eaclSDK.Header, 0, len(attrs))
|
||||
|
||||
for i := range attrs {
|
||||
hs = append(hs, attrs[i])
|
||||
res = append(res, attrs[i])
|
||||
}
|
||||
|
||||
res = append(res, hs...)
|
||||
}
|
||||
|
||||
return res
|
||||
|
|
Loading…
Reference in a new issue