perf: Remove duplicate overflow check from int.Mul (#18874)
This commit is contained in:
parent
bd04173012
commit
0c6b6d49cb
@ -41,6 +41,8 @@ Ref: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.j
|
||||
|
||||
* [#18421](https://github.com/cosmos/cosmos-sdk/pull/18421) Add mutative api for `LegacyDec.BigInt()`.
|
||||
|
||||
* [#18874](https://github.com/cosmos/cosmos-sdk/pull/18874) Speedup `math.Int.Mul` by removing a duplicate overflow check
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#18519](https://github.com/cosmos/cosmos-sdk/pull/18519) Prevent Overflow in `Dec.Ceil()`.
|
||||
|
||||
@ -333,12 +333,8 @@ func (i Int) MulRaw(i2 int64) Int {
|
||||
|
||||
// SafeMul multiples Int from another and returns an error if overflow
|
||||
func (i Int) SafeMul(i2 Int) (res Int, err error) {
|
||||
// Check overflow
|
||||
if i.i.BitLen()+i2.i.BitLen()-1 > MaxBitLen {
|
||||
return Int{}, ErrIntOverflow
|
||||
}
|
||||
res = Int{mul(i.i, i2.i)}
|
||||
// Check overflow if sign of both are same
|
||||
// Check overflow
|
||||
if res.i.BitLen() > MaxBitLen {
|
||||
return Int{}, ErrIntOverflow
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user