[#49] session: Make StableSize() zero-alloc

For this to work, it is necessary that `NestedStructureSize` is a generic function.
Otherwise, we would allocate to put it in the interface.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-07-26 18:12:48 +03:00
parent 6e92d7d5de
commit 43ad0f114c

View file

@ -211,7 +211,7 @@ func (c *ObjectSessionContext) StableMarshal(buf []byte) []byte {
}
offset := proto.EnumMarshal(objectCtxVerbField, buf, int32(c.verb))
proto.NestedStructureMarshal(objectCtxTargetField, buf[offset:], &objectSessionContextTarget{
proto.NestedStructureMarshal(objectCtxTargetField, buf[offset:], objectSessionContextTarget{
cnr: c.cnr,
objs: c.objs,
})
@ -225,7 +225,7 @@ func (c *ObjectSessionContext) StableSize() (size int) {
}
size += proto.EnumSize(objectCtxVerbField, int32(c.verb))
size += proto.NestedStructureSize(objectCtxTargetField, &objectSessionContextTarget{
size += proto.NestedStructureSize(objectCtxTargetField, objectSessionContextTarget{
cnr: c.cnr,
objs: c.objs,
})