Skip to content

Commit ab9da6a

Browse files
committed
Follow normal fast exit style, rather than nested ifs
1 parent 1b29fba commit ab9da6a

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

contracts/contracts/token/OUSD.sol

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -474,25 +474,26 @@ contract OUSD is Initializable, InitializableERC20Detailed, Governable {
474474
// Since there is no existing balance, we can directly set to
475475
// high resolution, and do not have to do any other bookkeeping
476476
nonRebasingCreditsPerToken[_account] = 1e27;
477-
} else {
478-
// This does not change, but if it did, we want want to
479-
// use the before changes value.
480-
uint256 oldCredits = _creditBalances[_account];
481-
482-
// Atomicly update account information:
483-
// It is important that balanceOf not be called inside updating
484-
// account data, since it will give wrong answers if it does
485-
// not have all an account's data in a consistent state.
486-
//
487-
// By setting a per account nonRebasingCreditsPerToken,
488-
// this account will no longer follow with the global
489-
// rebasing credits per token.
490-
nonRebasingCreditsPerToken[_account] = _rebasingCreditsPerToken;
491-
492-
// Update global totals:
493-
nonRebasingSupply = nonRebasingSupply.add(balanceOf(_account));
494-
_rebasingCredits = _rebasingCredits.sub(oldCredits);
477+
return;
495478
}
479+
480+
// This does not change, but if it did, we would want to
481+
// use the value before changes.
482+
uint256 oldCredits = _creditBalances[_account];
483+
484+
// Atomicly update account information:
485+
// It is important that balanceOf not be called inside updating
486+
// account data, since it will give wrong answers if it does
487+
// not have all an account's data in a consistent state.
488+
//
489+
// By setting a per account nonRebasingCreditsPerToken,
490+
// this account will no longer follow with the global
491+
// rebasing credits per token and will become non-rebasing.
492+
nonRebasingCreditsPerToken[_account] = _rebasingCreditsPerToken;
493+
494+
// Update global totals
495+
nonRebasingSupply = nonRebasingSupply.add(balanceOf(_account));
496+
_rebasingCredits = _rebasingCredits.sub(oldCredits);
496497
}
497498

498499
/**

0 commit comments

Comments
 (0)