Revert "[#59] util: Restore backwards compatibility in NestedStructureMarshal()"
This reverts commit c72590d831
.
This commit is contained in:
parent
499bb1ff2b
commit
ff2290fa93
2 changed files with 10 additions and 23 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.NestedStructureMarshalUnchecked(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.NestedStructureSizeUnchecked(objectCtxTargetField, objectSessionContextTarget{
|
size += proto.NestedStructureSize(objectCtxTargetField, objectSessionContextTarget{
|
||||||
cnr: c.cnr,
|
cnr: c.cnr,
|
||||||
objs: c.objs,
|
objs: c.objs,
|
||||||
})
|
})
|
||||||
|
|
|
@ -249,21 +249,12 @@ func VarUIntSize(x uint64) int {
|
||||||
return (bits.Len64(x|1) + 6) / 7
|
return (bits.Len64(x|1) + 6) / 7
|
||||||
}
|
}
|
||||||
|
|
||||||
type ptrStableMarshaler[T any] interface {
|
func NestedStructureMarshal[T stableMarshaller](field int64, buf []byte, v T) int {
|
||||||
stableMarshaller
|
n := v.StableSize()
|
||||||
~*T
|
if n == 0 {
|
||||||
}
|
|
||||||
|
|
||||||
func NestedStructureMarshal[T any, M ptrStableMarshaler[T]](field int64, buf []byte, v M) int {
|
|
||||||
if v == nil {
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return NestedStructureMarshalUnchecked(field, buf, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NestedStructureMarshalUnchecked[T stableMarshaller](field int64, buf []byte, v T) int {
|
|
||||||
n := v.StableSize()
|
|
||||||
prefix := protowire.EncodeTag(protowire.Number(field), protowire.BytesType)
|
prefix := protowire.EncodeTag(protowire.Number(field), protowire.BytesType)
|
||||||
offset := binary.PutUvarint(buf, prefix)
|
offset := binary.PutUvarint(buf, prefix)
|
||||||
offset += binary.PutUvarint(buf[offset:], uint64(n))
|
offset += binary.PutUvarint(buf[offset:], uint64(n))
|
||||||
|
@ -272,17 +263,13 @@ func NestedStructureMarshalUnchecked[T stableMarshaller](field int64, buf []byte
|
||||||
return offset + n
|
return offset + n
|
||||||
}
|
}
|
||||||
|
|
||||||
func NestedStructureSize[T any, M ptrStableMarshaler[T]](field int64, v M) (size int) {
|
func NestedStructureSize[T stableMarshaller](field int64, v T) (size int) {
|
||||||
if v == nil {
|
n := v.StableSize()
|
||||||
|
if n == 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
size = protowire.SizeGroup(protowire.Number(field), protowire.SizeBytes(n))
|
||||||
return NestedStructureSizeUnchecked(field, v)
|
return
|
||||||
}
|
|
||||||
|
|
||||||
func NestedStructureSizeUnchecked[T stableMarshaller](field int64, v T) int {
|
|
||||||
n := v.StableSize()
|
|
||||||
return protowire.SizeGroup(protowire.Number(field), protowire.SizeBytes(n))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Fixed64Marshal(field int, buf []byte, v uint64) int {
|
func Fixed64Marshal(field int, buf []byte, v uint64) int {
|
||||||
|
|
Loading…
Reference in a new issue