mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-25 05:40:49 +01:00
Optimize the MarshalMsgand allocate the memory only once.
This commit is contained in:
parent
c7eaaded9c
commit
6e8c4f56de
2 changed files with 12 additions and 12 deletions
|
@ -26,7 +26,7 @@ func (d Decimal) MarshalMsg(b []byte) ([]byte, error) {
|
|||
str = str[:sz]
|
||||
}
|
||||
|
||||
o, n := ensure(b, 1+sz)
|
||||
o, n := ensure(o, 1+sz)
|
||||
o[n] = byte(0xa0 | sz)
|
||||
n++
|
||||
|
||||
|
@ -54,7 +54,7 @@ func (d *Decimal) UnmarshalMsg(b []byte) ([]byte, error) {
|
|||
|
||||
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
|
||||
func (d Decimal) Msgsize() int {
|
||||
return 31
|
||||
return 32
|
||||
}
|
||||
|
||||
// Require ensures that cap(old)-len(old) >= extra.
|
||||
|
|
Loading…
Reference in a new issue