-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Open
Description
Small gas optimization in ReentrancyGuardTransient.sol by pre-computing the BooleanSlot
to avoid repeated type conversions.
Current:
REENTRANCY_GUARD_STORAGE.asBoolean().tstore(true);
Proposed:
TransientSlot.BooleanSlot private constant REENTRANCY_SLOT =
TransientSlot.BooleanSlot.wrap(REENTRANCY_GUARD_STORAGE);
// then use: REENTRANCY_SLOT.tstore(true);
Benefits
- Eliminates redundant
.asBoolean()
calls (currently called 3 times pernonReentrant
execution). - No functional changes. Same storage slot, same behavior.
- All existing tests pass without modification.
- Testing shows contracts save 1.3K gas at deployment plus 30 gas per
nonReentrant
modifier execution.
Would maintainers be interested in this micro-optimization? Happy to submit a PR if useful.
Metadata
Metadata
Assignees
Labels
No labels