refs: optimize marshalin of []ObjectID
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
94f068e462
commit
2aacaa6aba
1 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
package refs
|
package refs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
|
||||||
refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
|
refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/rpc/message"
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/message"
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/util/proto"
|
"github.com/nspcc-dev/neofs-api-go/v2/util/proto"
|
||||||
|
@ -114,8 +116,13 @@ func (o *ObjectID) StableSize() int {
|
||||||
// ObjectIDNestedListMarshal writes protobuf repeated ObjectID field
|
// ObjectIDNestedListMarshal writes protobuf repeated ObjectID field
|
||||||
// with fNum number to buf.
|
// with fNum number to buf.
|
||||||
func ObjectIDNestedListMarshal(fNum int64, buf []byte, ids []ObjectID) (off int) {
|
func ObjectIDNestedListMarshal(fNum int64, buf []byte, ids []ObjectID) (off int) {
|
||||||
|
prefix, _ := proto.NestedStructurePrefix(fNum)
|
||||||
for i := range ids {
|
for i := range ids {
|
||||||
off += proto.NestedStructureMarshal(fNum, buf[off:], &ids[i])
|
off += binary.PutUvarint(buf, prefix)
|
||||||
|
|
||||||
|
n := ids[i].StableSize()
|
||||||
|
off += binary.PutUvarint(buf[off:], uint64(n))
|
||||||
|
off += proto.BytesMarshal(objectIDValField, buf, ids[i].val)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue