From 620eb2a3be67c456eac95f1e470ab6e9383a67da Mon Sep 17 00:00:00 2001 From: Lawrence Date: Thu, 14 Mar 2019 15:48:38 -0400 Subject: [PATCH] Shave off an SLOAD op in ReentrancyGuard. --- contracts/utils/contracts/src/ReentrancyGuard.sol | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/contracts/utils/contracts/src/ReentrancyGuard.sol b/contracts/utils/contracts/src/ReentrancyGuard.sol index ca0d306629..ffe8b9df30 100644 --- a/contracts/utils/contracts/src/ReentrancyGuard.sol +++ b/contracts/utils/contracts/src/ReentrancyGuard.sol @@ -27,10 +27,8 @@ contract ReentrancyGuard { /// @dev Functions with this modifer cannot be reentered. modifier nonReentrant() { - // Increment the counter. - reentrancyGuardCounter += 1; - // Remember the current counter value. - uint256 localCounter = reentrancyGuardCounter; + // Increment and remember the current counter value. + uint256 localCounter = ++reentrancyGuardCounter; // Call the function. _; // If the counter value is different from what we remember,