forked from TrueCloudLab/frostfs-api-go
[#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:
parent
6e92d7d5de
commit
43ad0f114c
1 changed files with 2 additions and 2 deletions
|
@ -211,7 +211,7 @@ func (c *ObjectSessionContext) StableMarshal(buf []byte) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
offset := proto.EnumMarshal(objectCtxVerbField, buf, int32(c.verb))
|
offset := proto.EnumMarshal(objectCtxVerbField, buf, int32(c.verb))
|
||||||
proto.NestedStructureMarshal(objectCtxTargetField, buf[offset:], &objectSessionContextTarget{
|
proto.NestedStructureMarshal(objectCtxTargetField, buf[offset:], objectSessionContextTarget{
|
||||||
cnr: c.cnr,
|
cnr: c.cnr,
|
||||||
objs: c.objs,
|
objs: c.objs,
|
||||||
})
|
})
|
||||||
|
@ -225,7 +225,7 @@ func (c *ObjectSessionContext) StableSize() (size int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size += proto.EnumSize(objectCtxVerbField, int32(c.verb))
|
size += proto.EnumSize(objectCtxVerbField, int32(c.verb))
|
||||||
size += proto.NestedStructureSize(objectCtxTargetField, &objectSessionContextTarget{
|
size += proto.NestedStructureSize(objectCtxTargetField, objectSessionContextTarget{
|
||||||
cnr: c.cnr,
|
cnr: c.cnr,
|
||||||
objs: c.objs,
|
objs: c.objs,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue