From 2a124b95bc02c8a14f0d4d0dd3988efe331a6233 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Thu, 15 Feb 2024 14:41:33 +0300 Subject: [PATCH] [#64] object: Allow to reset marshal data Signed-off-by: Dmitrii Stepanov --- object/marshal.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/object/marshal.go b/object/marshal.go index 18172e6..7f47d65 100644 --- a/object/marshal.go +++ b/object/marshal.go @@ -346,16 +346,12 @@ func (o *Object) StableMarshal(buf []byte) []byte { // 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) { if o == nil { return } - if data == nil { - o.marshalData = o.StableMarshal(nil) - } else { - o.marshalData = data - } + o.marshalData = data } func (o *Object) StableSize() (size int) {