Code Optimization Tips

This tip submitted by Basker Swaminathan on 2005-08-26 01:41:22. It has been viewed 63353 times.
Rating of 5.5 with 366 votes

* if you've got a lot of if / else statements try to put the one most likely to be met first

* use a++ and a-- instead of a+=1 and a-=1

* even better, use ++a or --a instead of their post-increment versions. For primitive types, on some architectures, this will make a difference. For STL iterators, it's much more important and may save a lot of overhead.