From 838be05374e33f1c01cce85f7f2f44d6c237ff94 Mon Sep 17 00:00:00 2001 From: Shivam Agrawal Date: Sun, 24 Dec 2023 00:59:58 +0530 Subject: [PATCH] fix: minor optimization --- contracts/BatchTransaction.sol | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/contracts/BatchTransaction.sol b/contracts/BatchTransaction.sol index 7361c55..a3e122c 100644 --- a/contracts/BatchTransaction.sol +++ b/contracts/BatchTransaction.sol @@ -252,21 +252,18 @@ contract BatchTransaction is Basic, NitroMessageHandler, ReentrancyGuard { } function processRefunds(address user) internal { - uint256 len = tokensToRefund[user].tokens.length; + address[] memory tokens = tokensToRefund[user].tokens; + delete tokensToRefund[user].tokens; + + uint256 len = tokens.length; for (uint256 i = 0; i < len; ) { - withdrawTokens( - tokensToRefund[user].tokens[i], - user, - type(uint256).max - ); + withdrawTokens(tokens[i], user, type(uint256).max); unchecked { ++i; } } - - delete tokensToRefund[user]; } /**