diff --git a/docs/html/guide/practices/performance.jd b/docs/html/guide/practices/performance.jd index 078999becc393..3e2714cc965c0 100644 --- a/docs/html/guide/practices/performance.jd +++ b/docs/html/guide/practices/performance.jd @@ -168,20 +168,23 @@ signature that calling the method can't alter the object's state.

usually inline the access, and if you need to restrict or debug field access you can add the code at any time.

-

On Android, this is a bad idea. Virtual method calls are expensive, -much more so than instance field lookups. It's reasonable to follow +

On Android, this can be a bad idea. Virtual method calls can be more +expensive than instance field lookups. It's reasonable to follow common object-oriented programming practices and have getters and setters -in the public interface, but within a class you should always access +in the public interface, but within a class you might want to access fields directly.

Without a JIT, direct field access is about 3x faster than invoking a -trivial getter. With the JIT (where direct field access is as cheap as -accessing a local), direct field access is about 7x faster than invoking a -trivial getter. This is true in Froyo, but will improve in the future when -the JIT inlines getter methods.

+trivial getter (one that simply returns the value of a field, without +any dereferencing or array indexing). With the Froyo JIT, direct field +access was about 7x faster than invoking a trivial getter. Since +Gingerbread, though, the JIT inlines trivial getter methods, making +that particular optimization obsolete. Manual inlining guided by +profiling can still be a useful technique in general, though.

Note that if you're using ProGuard, you can have the best -of both worlds because ProGuard can inline accessors for you.

+of both worlds even with non-trival accessors, because ProGuard can inline +for you.

Use Static Final For Constants