O'Reilly logo

Pro Android Apps Performance Optimization by Hervé Guihot

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tips

The following are a few things you can do in your code relatively easily to achieve better performance.

Inlining Functions

Because function calls can be expensive operations, inlining functions (that is, the process of replacing the function call with the body of the function itself) can make your code run faster. Making a function inlined is simply a matter of adding the “inline” keyword as part of its definition. An example of inline function is showed in Listing 3–30.

You should use this feature carefully though as it can result in bloated code, negating the advantages of the instruction cache. Typically, inlining works better for small functions, where the overhead of the call itself is significant.

NOTE: Alternatively, use macros. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required