diff --git a/pkg/services/object/acl/eacl/v2/object.go b/pkg/services/object/acl/eacl/v2/object.go index a31059de8..ec610aeb6 100644 --- a/pkg/services/object/acl/eacl/v2/object.go +++ b/pkg/services/object/acl/eacl/v2/object.go @@ -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