However, it seems the OP is more interested in best practices. Writing overall better code I think is worth it, so long as you don't constantly refactor.
Quote:Original post by Decrius
I'm not too familiar with ASM, but I can read it a bit. Exporting the ASM sources sounds like a solid idea...using Release mode and the optimizations I'd use when I'd distribute it...
Two tips:
First, do not allow your compiler to inline functions when you look at asm. This makes it so you'll know where to look. While this isn't exactly a realistic condition, it just lets you see what the code looks like. Alternatively, with gcc, I can do inline assembly like so: asm("# comment"); and when I compile with -S, I can see exactly where the function is implemented. (There are ways to have g++ print the source and assembly together, but I find the assembly gets mangled so I rely on my own methods.)
Second, know that compilers don't do the obvious thing. For example, try dividing by seven. So, what you look at might not be clear at all. But, if you post here, I think we can help make sense of assembly.
On the increment thing: I think some compilers can tell how to increment i even if it's not an integer or a pointer. And i++ is sometimes actually faster according to the optimization guide I linked. It says that the cpu needs the address of the variable it's going to load so many cycles ahead of time, so i++ will be faster when loading from memory because the address can already be calculated.
x = array[i++]
is faster than x = array[++i]
I think it's best to use ++i most of the time just so you KNOW it's optimized, but it sounds like speed(i++) CAN be greater than speed(++i).