object: Allow to reset marshal data #64

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-api-go:fix/reset_marshalled_data into master 2024-02-15 11:58:43 +00:00

View file

@ -346,16 +346,12 @@ func (o *Object) StableMarshal(buf []byte) []byte {
// SetMarshalData sets marshal data to reduce memory allocations. // SetMarshalData sets marshal data to reduce memory allocations.
// //
// It is unsafe to modify object data after setting marshal data. // It is unsafe to modify/copy object data after setting marshal data.
func (o *Object) SetMarshalData(data []byte) { func (o *Object) SetMarshalData(data []byte) {
if o == nil { if o == nil {
return return
} }
if data == nil {
o.marshalData = o.StableMarshal(nil)
} else {
o.marshalData = data o.marshalData = data
}
} }
func (o *Object) StableSize() (size int) { func (o *Object) StableSize() (size int) {