In the Notepad Exercise 2, there is a section about perf (see excerpt)

*Note:* We assign the mNotesCursor field to a local variable at the start of
the method. This is done as an optimization of the Android code. Accessing a
local variable is much more efficient than accessing a field in the Dalvik
VM, so by doing this we make only one access to the field, and five accesses
to the local variable, making the routine much more efficient. It is
recommended that you use this optimization when possible.

Can someone tell me in a bit more precise terms how "much more efficient" is
to use a local variable? I'm trying to weigh the perf benefit vs. code
readability/maintainability. It is a pain to reassign n fields to n local
variables for m methods...

Thanks!

-dave

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to