As of Android 1.1, the compiler and VM are pretty dumb when it comes to automatic optimization. There is no just-in-time compilation or escape analysis or anything like that. At last year's Google I/O conference I asked designer Dan Bornstein about this and he said they were trying to make the VM as small and simple as possible in the first version. So if you have a tight loop, simple things like hoisting common subexpressions and memory allocation out of the loop can make a big difference. According to Dan, they have plenty of ideas for improving things in the future so that existing code will run faster. But for now, that's what you have to put up with.