Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d5c5111 authored by Elliott Hughes's avatar Elliott Hughes Committed by Android Git Automerger
Browse files

am 3c04cc44: Merge "Don\'t talk about Froyo as if it\'s still in the future."

* commit '3c04cc44':
  Don't talk about Froyo as if it's still in the future.
parents c36b8acd 3c04cc44
Loading
Loading
Loading
Loading
+11 −8
Original line number Original line Diff line number Diff line
@@ -168,20 +168,23 @@ signature that calling the method can't alter the object's state.</p>
usually inline the access, and if you need to restrict or debug field access
usually inline the access, and if you need to restrict or debug field access
you can add the code at any time.</p>
you can add the code at any time.</p>


<p>On Android, this is a bad idea.  Virtual method calls are expensive,
<p>On Android, this can be a bad idea.  Virtual method calls can be more
much more so than instance field lookups.  It's reasonable to follow
expensive than instance field lookups.  It's reasonable to follow
common object-oriented programming practices and have getters and setters
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.</p>
fields directly.</p>


<p>Without a JIT, direct field access is about 3x faster than invoking a
<p>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
trivial getter (one that simply returns the value of a field, without
accessing a local), direct field access is about 7x faster than invoking a
any dereferencing or array indexing). With the Froyo JIT, direct field
trivial getter. This is true in Froyo, but will improve in the future when
access was about 7x faster than invoking a trivial getter. Since
the JIT inlines getter methods.</p>
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.</a>


<p>Note that if you're using ProGuard, you can have the best
<p>Note that if you're using ProGuard, you can have the best
of both worlds because ProGuard can inline accessors for you.</p>
of both worlds even with non-trival accessors, because ProGuard can inline
for you.</p>


<a name="use_final" id="use_final"></a>
<a name="use_final" id="use_final"></a>
<h2>Use Static Final For Constants</h2>
<h2>Use Static Final For Constants</h2>