Skip to content

Commit

Permalink
refactor(forwarder): refactor targets.length into a variable for gas-…
Browse files Browse the repository at this point in the history
…saving
  • Loading branch information
oliviera9 committed Mar 12, 2024
1 parent fd3a021 commit 5cbceea
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contracts/forwarder/Forwarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ contract Forwarder is Context, Ownable, IERC777Recipient, IForwarder, IPReceiver

(bytes memory callsAndTargets, address caller) = abi.decode(userData, (bytes, address));
(address[] memory targets, bytes[] memory data) = abi.decode(callsAndTargets, (address[], bytes[]));
uint256 targetsLength = targets.length;

if (targets.length != data.length) revert InvalidCallParams(targets, data, originNetworkId, caller);
if (targetsLength != data.length) revert InvalidCallParams(targets, data, originNetworkId, caller);

for (uint256 i = 0; i < targets.length; ) {
for (uint256 i = 0; i < targetsLength; ) {
// NOTE: avoid to check the caller if function is approve
if (!_unprivilegedCalls[bytes4(data[i])]) {
bytes memory addrSlot = BytesLib.slice(data[i], 4, 36);
Expand Down

0 comments on commit 5cbceea

Please sign in to comment.