4 ms·
Yes, but if used as their own statement and not used as some bigger expression (parameter to function, etc.), any decent compiler will compile them the same way
by colejohnson66 9y ago
Yes, but if used as their own statement and not used as some bigger expression (parameter to function, etc.), any decent compiler will compile them the same way.
- gnaritas 9y agoYes, and thus a perfect example premature optimization; semantics should define default usage, not some possible micro optimization. This is exactly the kind of case Knuth is talking about, going around doing ++x because you think it's faster when the standard idiom is x++ is premature optimization.
- marcosdumay 9y agoWell, there is no reason for any standard idiom there. Those `++` and `--` operators are something to avoid anyway.
- zerr 9y agox++ is not the "standard idiom".
- jcelerier 9y agoNotice how the asm changes here if changing it++ to ++it: https://godbolt.org/g/W5w7Dc https://godbolt.org/g/W5w7Dc