diff --git a/CHANGELOG.md b/CHANGELOG.md index cfe08c13ccf6d..50ae73502d60d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Improvements +* (types) [\#10021](https://github.com/cosmos/cosmos-sdk/pull/10021) Speedup coins.AmountOf(), by removing many intermittent regex calls. + ### Bug Fixes * (x/genutil) [#10104](https://github.com/cosmos/cosmos-sdk/pull/10104) Ensure the `init` command reads the `--home` flag value correctly. diff --git a/types/coin.go b/types/coin.go index 52155a6edd139..e24dd22d02118 100644 --- a/types/coin.go +++ b/types/coin.go @@ -736,6 +736,7 @@ func (coins Coins) Find(denom string) (bool, Coin) { return false, Coin{} default: + // Binary search the amount of coins remaining midIdx := len(coins) / 2 // 2:1, 3:1, 4:2 coin := coins[midIdx] switch {