Skip to content

Commit

Permalink
apply gas opt for BucketLimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
seongyun-ko committed Dec 30, 2024
1 parent bdee463 commit d40a117
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/BucketLimiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ library BucketLimiter {
function _refill(Limit memory limit) internal view {
// We allow for overflow here, as the delta is resilient against it.
uint64 now_ = uint64(block.timestamp);

if (now_ == limit.lastRefill) {
return;
}

uint64 delta;
unchecked {
delta = now_ - limit.lastRefill;
Expand Down

0 comments on commit d40a117

Please sign in to comment.