diff --git a/CHANGELOG.md b/CHANGELOG.md index f3093bf90..8c2f9f92b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * `ReentrancyGuard`: Add a `_reentrancyGuardEntered` function to expose the guard status. ([#3714](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3714)) * `ERC20Votes`: optimize by using unchecked arithmetic. ([#3748](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3748)) + * `Initializable`: optimize `_disableInitializers` by using `!=` instead of `<`. ([#3787](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3787)) ## Unreleased diff --git a/contracts/proxy/utils/Initializable.sol b/contracts/proxy/utils/Initializable.sol index 51d4be7f4..d0110f0fc 100644 --- a/contracts/proxy/utils/Initializable.sol +++ b/contracts/proxy/utils/Initializable.sol @@ -143,7 +143,7 @@ abstract contract Initializable { */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); - if (_initialized < type(uint8).max) { + if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); }