✒️Gas Saving Technique 21: Unneeded If statements
Introduction
Impact & Details
Example: Removing Unneeded 'If' Statements
solidityCopy codepragma solidity ^0.8.0;
contract ExampleContract {
function cleanUp(bytes32 claimIdentifier) external {
if (_setState(claimIdentifier, State.NonExistent) != State.Cleaned) {
revert InvalidState(); // This check might be unnecessary
}
// ... rest of the function ...
}
}Recommended Mitigation Steps
Conclusion
PreviousGas Saving Technique 20: Storage vs Memory read optimizationsNextGas Saving Technique 22: >= is cheaper than >
Last updated