2 ms·
I was speaking in the context of two different frameworks, not code, but I suppose the clarification is nessesary. > I one worked with someone who changed all
by hvidgaard 8y ago
I was speaking in the context of two different frameworks, not code, but I suppose the clarification is nessesary.
> I one worked with someone who changed all i++'s in a codebase to ++i's
Did you use the previous value of i, or did you just intent to increment it? ++i communicate that I'm not interested in the old value, where as i++ does the opposite. I actually use it as such, because my intent to a future reader of the code is more clear.
That said, for complex types, and with "stupid" compilers ++i can absolutely be significantly faster.
- Vinnl 8y ago> Did you use the previous value of i, or did you just intent to increment it? ++i communicate that I'm not interested in the old value, where as i++ does the opposite. I actually use it as such, because my intent to a future reader of the code is more clear. I would consider that a valid reason to use ++i. In this case, however, he indicated performance as being the reason. Furthermore, this was for a school assignment demonstrating that we could properly implement a particular algorithm, so the performance difference was absolutely irrelevant.