dss icon indicating copy to clipboard operation
dss copied to clipboard

Return early if `now == rho`.

Open MicahZoltu opened this issue 5 years ago • 2 comments

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.

MicahZoltu avatar Oct 31 '19 02:10 MicahZoltu

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.

epheph avatar Oct 31 '19 20:10 epheph

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.

godsflaw avatar Nov 11 '19 15:11 godsflaw