Skip to content

[RTU-02C] Redundant Conditional Clause #16

@dkuppitz

Description

@dkuppitz

RTU-02C: Redundant Conditional Clause

Type Severity Location
Gas Optimization RebaseTokenUpgradeable.sol:L78

Description:

The RebaseTokenUpgradeable::_disableRebase function is solely invoked within USTB::disableRebase whereby the new disable state of the account is guaranteed to be different.

Example:

function _disableRebase(address account, bool disable) internal {
    RebaseTokenStorage storage $ = _getRebaseTokenStorage();
    if ($.optOut[account] != disable) {
        uint256 balance = balanceOf(account);
        $.optOut[account] = disable;
        if (balance != 0) {
            if (disable) {
                RebaseTokenUpgradeable._update(account, address(0), balance);
                ERC20Upgradeable._update(address(0), account, balance);
            } else {
                ERC20Upgradeable._update(account, address(0), balance);
                RebaseTokenUpgradeable._update(address(0), account, balance);
            }
        }
        if (disable) emit RebaseDisabled(account);
        else emit RebaseEnabled(account);
    }
}

Recommendation:

We advise the referenced conditional to be omitted from the codebase, optimizing the gas cost of the function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions