Code Optimization TipsThis tip submitted by Basker Swaminathan on 2005-08-26 01:41:22. It has been viewed 51853 times.
Rating of 6.5 with 280 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.
Help your fellow programmers! Add a tip!