Skip to content

Commit

Permalink
core/state: short-circuit balance change if zero value
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustav Simonsson committed Sep 26, 2016
1 parent 3778f1b commit 25ed5fe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ func (self *StateObject) Update() {
}

func (c *StateObject) AddBalance(amount *big.Int) {
if amount.Cmp(common.Big0) == 0 {
return
}
c.SetBalance(new(big.Int).Add(c.balance, amount))

if glog.V(logger.Core) {
Expand All @@ -160,6 +163,9 @@ func (c *StateObject) AddBalance(amount *big.Int) {
}

func (c *StateObject) SubBalance(amount *big.Int) {
if amount.Cmp(common.Big0) == 0 {
return
}
c.SetBalance(new(big.Int).Sub(c.balance, amount))

if glog.V(logger.Core) {
Expand Down

0 comments on commit 25ed5fe

Please sign in to comment.