On Tue, Jan 6, 2009 at 12:14 AM, Dave Kong <[email protected]> wrote:
> So the perf optimization documented is just the same as in regular java > app, or for that matter, any OO language. I was afraid that for Dalvik VM, > the cost of accessing member variable is disproportionally large. Perhaps > the HW makes this optimzation more worthwhile. The point of this is that you are writing code for an embedded device, where every wasted amount of work comes directly from the battery. It is just a good habit to write efficient code. > I understand it's good practice to use local vars whenever possible. > However, in a typical android app, I can easily have say ~10 member > variables (TextView), and if I use most of them in different methods, it > gets a little annoying copying 10 local variable assignments to each method. > So I'd rather not track their usage in each method. =) If you are only accessing the variable a couple times in a method, there is no point in putting it in a local variable. Otherwise it is good to do. My personal experience is that being judicious about it has very little impact on the resulting code. -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

