Browse Source

caching result of reading storage variable to save gas (#4535)

Molly 2 năm trước cách đây
mục cha
commit
b2e7bab920
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      contracts/proxy/utils/Initializable.sol

+ 2 - 1
contracts/proxy/utils/Initializable.sol

@@ -106,7 +106,8 @@ abstract contract Initializable {
         InitializableStorage storage $ = _getInitializableStorage();
 
         bool isTopLevelCall = !$._initializing;
-        if (!(isTopLevelCall && $._initialized < 1) && !(address(this).code.length == 0 && $._initialized == 1)) {
+        uint64 initialized = $._initialized;
+        if (!(isTopLevelCall && initialized < 1) && !(address(this).code.length == 0 && initialized == 1)) {
             revert AlreadyInitialized();
         }
         $._initialized = 1;