Skip to content

Commit 7c9cb7f

Browse files
Cache expires to save gas (#51)
1 parent 7447bb1 commit 7c9cb7f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/L2/BaseRegistrar.sol

+6-4
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,13 @@ contract BaseRegistrar is ERC721, Ownable {
260260
///
261261
/// @return The new expiry date.
262262
function renew(uint256 id, uint256 duration) external live onlyController returns (uint256) {
263-
if (nameExpires[id] + GRACE_PERIOD < block.timestamp) revert NotRegisteredOrInGrace(id);
263+
uint256 expires = nameExpires[id];
264+
if (expires + GRACE_PERIOD < block.timestamp) revert NotRegisteredOrInGrace(id);
264265

265-
nameExpires[id] += duration;
266-
emit NameRenewed(id, nameExpires[id]);
267-
return nameExpires[id];
266+
expires += duration;
267+
nameExpires[id] = expires;
268+
emit NameRenewed(id, expires);
269+
return expires;
268270
}
269271

270272
/// @notice Reclaim ownership of a name in ENS, if you own it in the registrar.

0 commit comments

Comments
 (0)