Skip to content

Commit 3c04cc4

Browse files
enh-googleandroid code review
authored andcommitted
Merge "Don't talk about Froyo as if it's still in the future."
2 parents 8d17042 + 79d95ac commit 3c04cc4

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

docs/html/guide/practices/performance.jd

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,23 @@ signature that calling the method can't alter the object's state.</p>
168168
usually inline the access, and if you need to restrict or debug field access
169169
you can add the code at any time.</p>
170170

171-
<p>On Android, this is a bad idea. Virtual method calls are expensive,
172-
much more so than instance field lookups. It's reasonable to follow
171+
<p>On Android, this can be a bad idea. Virtual method calls can be more
172+
expensive than instance field lookups. It's reasonable to follow
173173
common object-oriented programming practices and have getters and setters
174-
in the public interface, but within a class you should always access
174+
in the public interface, but within a class you might want to access
175175
fields directly.</p>
176176

177177
<p>Without a JIT, direct field access is about 3x faster than invoking a
178-
trivial getter. With the JIT (where direct field access is as cheap as
179-
accessing a local), direct field access is about 7x faster than invoking a
180-
trivial getter. This is true in Froyo, but will improve in the future when
181-
the JIT inlines getter methods.</p>
178+
trivial getter (one that simply returns the value of a field, without
179+
any dereferencing or array indexing). With the Froyo JIT, direct field
180+
access was about 7x faster than invoking a trivial getter. Since
181+
Gingerbread, though, the JIT inlines trivial getter methods, making
182+
that particular optimization obsolete. Manual inlining guided by
183+
profiling can still be a useful technique in general, though.</a>
182184

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

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

0 commit comments

Comments
 (0)