Skip to content

Comment on Speedup from switch to +=

Comments

But wait... x+=y is equivalent to x=x+y not to x=y+x. Only if + is commutative, then the three are equivalent. Are we sure the + operation is commutatve for this type of data? And does the compiler know it?

It would be interesting to check whether changing every expression to x=x+y has a performance more similar to += or to ...+x

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.