Closed PaulRBerg closed 1 year ago
I made a gas comparison now. What I did:
method
defined within the loop)PRBProxyRegistry
with the method
defined outside the loop (as suggested by @IaroslavMazur)
optimized
profile when deployingBreakdown:
Tx | Gas Cost |
---|---|
Inside the Loop | 122,310 |
Outside the Loop | 122,358 |
Thus, contrary to our expectations, declaring method
outside the loop increases the cost. And the reason for this is via IR - speaking of which, I've tweeted about how surprising via IR can be here.
Thus, contrary to our expectations, declaring
method
outside the loop increases the cost. And the reason for this is via IRhere.
How very weird, indeed! 🤔
Thank you for diving into this!
This is @IaroslavMazur's suggestion:
The reference is for the
method
variable declaration here:https://github.com/PaulRBerg/prb-proxy/blob/27594d50f049330c5acfa6cf45448152a2932ecf/src/PRBProxyRegistry.sol#L264