[#65] object: Fix SetMarshalData for PutSingle request
All checks were successful
DCO action / DCO (pull_request) Successful in 1m11s
Tests and linters / Tests (1.20) (pull_request) Successful in 1m25s
Tests and linters / Tests (1.19) (pull_request) Successful in 1m33s
Tests and linters / Tests with -race (pull_request) Successful in 1m56s
Tests and linters / Lint (pull_request) Successful in 1m14s
All checks were successful
DCO action / DCO (pull_request) Successful in 1m11s
Tests and linters / Tests (1.20) (pull_request) Successful in 1m25s
Tests and linters / Tests (1.19) (pull_request) Successful in 1m33s
Tests and linters / Tests with -race (pull_request) Successful in 1m56s
Tests and linters / Lint (pull_request) Successful in 1m14s
Allow to reset marshal data Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
2a124b95bc
commit
634e24aba7
2 changed files with 7 additions and 6 deletions
|
@ -1111,17 +1111,13 @@ func (r *PutSingleRequestBody) StableMarshal(buf []byte) []byte {
|
|||
|
||||
// SetMarshalData sets marshal data to reduce memory allocations.
|
||||
//
|
||||
// It is unsafe to modify request data after setting marshal data.
|
||||
// It is unsafe to modify/copy request data after setting marshal data.
|
||||
func (r *PutSingleRequestBody) SetMarshalData(data []byte) {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
r.marshalData = r.StableMarshal(nil)
|
||||
} else {
|
||||
r.marshalData = data
|
||||
}
|
||||
r.marshalData = data
|
||||
|
||||
proto.NestedStructureSetMarshalData(putSingleReqObjectField, r.marshalData, r.object)
|
||||
}
|
||||
|
|
|
@ -287,6 +287,11 @@ func NestedStructureSetMarshalData[T any, M setMarshalData[T]](field int64, pare
|
|||
return 0
|
||||
}
|
||||
|
||||
if parentData == nil {
|
||||
v.SetMarshalData(nil)
|
||||
return 0
|
||||
}
|
||||
|
||||
n := v.StableSize()
|
||||
buf := make([]byte, binary.MaxVarintLen64)
|
||||
prefix := protowire.EncodeTag(protowire.Number(field), protowire.BytesType)
|
||||
|
|
Loading…
Reference in a new issue