OpenZeppelin/openzeppelin-contracts

Optimization in Address.sol::verifyCallResultFromTarget()

Z323323 opened this issue · 2 comments

Line 124 -> if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
There's no need to check returndata.length because if target.code.length is == 0 then returndata.length is always 0.

You're right, but getting the code size costs 100 gas, so bailing out after checking returndata.length costing just 3 in many cases will be cheaper despite the worst case scenario being marginally more expensive.

True, closing issue.