dss
dss copied to clipboard
Return early if `now == rho`.
https://github.com/makerdao/dss/blob/effdda3657f71fd6efc3465dc661b375d1bacc3e/src/pot.sol#L138
This function is a no-op if rho == now
. Rather than wasting a bunch of effort (gas) executing this function in that case, it should just return early. While the caller can do if (pot.rho != now) pot.drip()
, it is much more expensive for them to do this than it is for this method to do that.
This proposed optimization seems especially impactful as each run executes 5 SSTOREs (all rewriting the same value after either adding 0 or multiplying by 1) and many more SLOADs.
The if statement @MicahZoltu is proposing would save over 30K gas per call.
I think we should keep this issue open in case we want to resurrect this PR in the chance governance ever decided to upgrade these contracts.