Which is faster, dividing by four or shifting by two?
Should I make this array of 10 numbers shorts instead of ints to save on space?
What are your favorite tips and tricks for speeding up programs?
I get a lot of questions like these from real-world developers who think they might have performance problems. Though those developers mean well, these are almost always the wrong questions to ask! Why? Because knowing the answers will not actually lead to improvements that any user will notice. A program that downloads and displays a hundred million bytes of video from a server on the other side of the world is not going to suddenly become smooth and fluid because you saved a couple nanoseconds in one math routine or trimmed 20 bytes from ...