Gas comparisons of ++ before, after and += 1 Solidity 0.8.10

ProgrammerSmart's tweet image. Gas comparisons of ++ before, after and += 1
Solidity 0.8.10

How are you running this example? It seems wild to me that it costs this much, there definitely is an unnecessary storage write happening somewhere for it to costs more than 23000


Ser you ready for gas wars ?


Gas price is low. There is no war to fight


Wild - hopefully in 1.0.0 a lot of these compiler oddities will be fixed?


I like writing solidity cause just like me, the output depends on how u ask me 🤠


true but what about the stylistic points gained from using post increment? Might make up for the 6 gas saved 😅


lol lots of rarities with solidity


I wonder why this ‘optimization’ isn’t done regardless of what the programmer writes. The increments yield the same value and don’t rely on any external variables prior to computation, so precomputing this always seems reasonable, doesn’t it?


That's really interesting, even between post increment operator and +=1 there's a gas difference!😯


Does this also affect incrementing in loops?


L2'22 is near, then nobody will talk about gas


I must be living through one hell of a lie if these are more efficient.


United States Trends
Loading...

Something went wrong.


Something went wrong.