> i.e. use ++i or --i in place of i++ or i--.
In the context of a for loop
, where you're just using the operator for it's side effect, I've never seen it make a bean of difference whether you write
i += 1
i = i + 1
Any decent compiler will easily recognise all those things as meaning the same thing, and generate exactly the same code.
Study the output of "gcc -S prog.c" (result in prog.s) to view the generated assembler.
You're dealing with a compiler, not a programmable calculator. It doesn't perform a literal translation of each character you type into a machine instruction. If the old result of say i++ is never referenced, then it simply won't exist in the executable program.
> 5. Always Declare any multi dimensions Array with the power Of 2.
Why, what about all that wasted space?
> Because Reason is same as i have given in 4.
Except array subscripting is based on multiplication, not raising 2 to the power of something.
Modern compilers like gcc will optimise a great many more numbers as efficient shift/add combinations than the obvious powers of 2 which you seem to like.
This all smacks of premature optimisation disease.
You've got to make it "right" before you can make it "fast". A bug-ridden program which is delivered late is no use to anyone, no matter how fast it is.
Besides which, you need a working program to test with meaningful data if you're to get anything useful at all out of profiling. Profiling will tell you where the real hot spots are, not your guesses based on some hearsay evidence from some web page. Many (if not all) of the old tricks simply don't apply to today's optimising compilers.
Try this if you want to find out more.