Androidinous Efficiency: To bool or not to bool?
Wednesday, March 4th, 2009A common belief among programmers is that you should write code that says what you mean, because the compiler will probably do a better job at optimising than you can do off the top of your head.
On the other hand, Writing Efficient Android Code says “It is unwise to rely on a compiler to “save” you and make your code fast enough” and recommends that programmers do things like caching member variables (like array lengths) in local variables. This isn’t just premature optimisation; it’s trivial stuff we expect the most basic compilers to handle!
To understand why, it helps to know how your code ends up running on device: