perf: Remove unneeded cmp in Ceil and marshalTo (#19467)
This commit is contained in:
parent
16b19638ef
commit
0f113520f9
@ -43,6 +43,7 @@ Ref: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.j
|
||||
|
||||
* [#18874](https://github.com/cosmos/cosmos-sdk/pull/18874) Speedup `math.Int.Mul` by removing a duplicate overflow check
|
||||
* [#19386](https://github.com/cosmos/cosmos-sdk/pull/19386) Speedup `math.Int` overflow checks
|
||||
* [#19467](https://github.com/cosmos/cosmos-sdk/pull/19467) Slightly speedup `math.LegacyDec` `Ceil` and `MarshalTo` methods
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
||||
@ -734,11 +734,9 @@ func (d LegacyDec) Ceil() LegacyDec {
|
||||
quo, rem = quo.QuoRem(tmp, precisionReuse, rem)
|
||||
|
||||
// no need to round with a zero remainder regardless of sign
|
||||
if rem.Cmp(zeroInt) == 0 {
|
||||
if rem.Sign() == 0 {
|
||||
return LegacyNewDecFromBigInt(quo)
|
||||
}
|
||||
|
||||
if rem.Sign() == -1 {
|
||||
} else if rem.Sign() == -1 {
|
||||
return LegacyNewDecFromBigInt(quo)
|
||||
}
|
||||
|
||||
@ -847,7 +845,7 @@ func (d *LegacyDec) MarshalTo(data []byte) (n int, err error) {
|
||||
i = new(big.Int)
|
||||
}
|
||||
|
||||
if i.Cmp(zeroInt) == 0 {
|
||||
if i.Sign() == 0 {
|
||||
copy(data, []byte{0x30})
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user