smartcontractkit / huff-starter-kit

A template repo to work with huff smart contracts and learn about low level EVM opcodes. Also Horse ♘.
101 stars 13 forks source link

Fix Memory Management #5

Closed Kuly14 closed 1 year ago

Kuly14 commented 1 year ago

In KeepersConsumer.CHECK_UPKEEP() you pushed four values to the stack, which meant that in PERFROM_UPKEEP, you had to pop three items off to use the time_comparison.

This was unnecessary since only the CHECK_UPKEEP() function uses those values. I pushed them onto the stack inside the CHECK_UPKEEP() function. This means we save at least nine gas in the PERFORM_UPKEEP() function because we got rid of the three pop opcodes.

This makes the code more readable, cleaner, and optimized.

PatrickAlphaC commented 1 year ago

Oh wow! Yes this is much better.

I was thinking with those three pops that they were so ugly.