From 43ad0f114cf5ce5bd516b933ed08f721d27741a8 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 26 Jul 2023 18:12:48 +0300 Subject: [PATCH] [#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 --- session/marshal.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/session/marshal.go b/session/marshal.go index 3c56cd4..cda9579 100644 --- a/session/marshal.go +++ b/session/marshal.go @@ -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, })