Skip to content

Commit

Permalink
Added anohter loop to check if a zero coin exists before allocating s…
Browse files Browse the repository at this point in the history
…pace
  • Loading branch information
waggonerjake committed Oct 11, 2021
1 parent 3637270 commit 80fb841
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion types/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,16 @@ func (coins Coins) negative() Coins {

// removeZeroCoins removes all zero coins from the given coin set in-place.
func removeZeroCoins(coins Coins) Coins {
result := make([]Coin, 0, len(coins))
result := ([]Coin)(nil)

for i := 0; i < len(coins); i++ {
if coins[i].IsZero() {
result = make([]Coin, 0, len(coins))
break
} else if i == len(coins)-1 {
return coins
}
}

for _, coin := range coins {
if !coin.IsZero() {
Expand Down

0 comments on commit 80fb841

Please sign in to comment.