[#64] object: Allow to reset marshal data
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com> Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
1fde449a15
commit
12567d76a8
1 changed files with 2 additions and 6 deletions
|
@ -346,17 +346,13 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Object) StableSize() (size int) {
|
||||
if o == nil {
|
||||
|
|
Loading…
Reference in a new issue