The linked statements will result in no-ops if the _amount that is passed to setDepositsReleased is zero.
Example:
/**
* @notice Mark voucher token that the deposits were released
* @param _tokenIdVoucher ID of the voucher token
* @param _to recipient, one of {ISSUER, HOLDER, POOL}
* @param _amount amount that was released in the transaction
*/
function setDepositsReleased(uint256 _tokenIdVoucher, Entity _to, uint256 _amount)
external
override
onlyFromCashier
{
require(_tokenIdVoucher != 0, "UNSPECIFIED_ID");
vouchersStatus[_tokenIdVoucher].depositReleased.status |= (ONE << uint8(_to));
vouchersStatus[_tokenIdVoucher].depositReleased.releasedAmount = vouchersStatus[_tokenIdVoucher].depositReleased.releasedAmount.add(_amount);
if (vouchersStatus[_tokenIdVoucher].depositReleased.releasedAmount == getTotalDeposits(_tokenIdVoucher)) {
vouchersStatus[_tokenIdVoucher].isDepositsReleased = true;
emit LogFundsReleased(_tokenIdVoucher, 1);
}
}
Recommendation:
We advise a conditional to be introduced before the linked statements that will halt execution of the function if the _amount is zero.
VKL-01C: Statement Execution Optimization
Description:
The linked statements will result in no-ops if the
_amount
that is passed tosetDepositsReleased
is zero.Example:
Recommendation:
We advise a conditional to be introduced before the linked statements that will halt execution of the function if the
_amount
is zero.