Skip to content

Commit

Permalink
chore: apply micro optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
hallazzang committed Jun 2, 2022
1 parent 7d2c5e3 commit 9d14b9b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion x/liquidity/amm/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func (ob *OrderBook) InstantMatch(ctx MatchContext, lastPrice sdk.Dec) (matched
}
buySums = append(buySums, sum)
}
if len(buySums) == 0 {
return false
}
sellSums := make([]sdk.Int, 0, len(ob.sells.ticks))
for i, sellTick := range ob.sells.ticks {
if sellTick.price.GT(lastPrice) {
Expand All @@ -88,7 +91,7 @@ func (ob *OrderBook) InstantMatch(ctx MatchContext, lastPrice sdk.Dec) (matched
}
sellSums = append(sellSums, sum)
}
if len(buySums) == 0 || len(sellSums) == 0 {
if len(sellSums) == 0 {
return false
}
matchAmt := sdk.MinInt(buySums[len(buySums)-1], sellSums[len(sellSums)-1])
Expand Down

0 comments on commit 9d14b9b

Please sign in to comment.