perf: Remove an extra heap allocation from NewLegacyDec (#19466)
Co-authored-by: Marko <marbar3778@yahoo.com>
This commit is contained in:
parent
b098abfcac
commit
4db9838ae6
@ -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
|
||||
* [#19466](https://github.com/cosmos/cosmos-sdk/pull/19466) Speedup `math.NewLegacyDec` by one heap allocation
|
||||
* [#19467](https://github.com/cosmos/cosmos-sdk/pull/19467) Slightly speedup `math.LegacyDec` `Ceil` and `MarshalTo` methods
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@ -102,8 +102,9 @@ func LegacyNewDec(i int64) LegacyDec {
|
||||
// create a new Dec from integer with decimal place at prec
|
||||
// CONTRACT: prec <= Precision
|
||||
func LegacyNewDecWithPrec(i, prec int64) LegacyDec {
|
||||
bi := big.NewInt(i)
|
||||
return LegacyDec{
|
||||
new(big.Int).Mul(big.NewInt(i), precisionMultiplier(prec)),
|
||||
bi.Mul(bi, precisionMultiplier(prec)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user