I'm not sure about DalvikVM, but some compilers take advantage of
'final'.

E.g.
Final variables can be put in registers of the CPU without worrying
that they may change during execution (constantly moving variable-
values back and forth from memory to registers could be omitted for
'final' vars).

Or the compiler itself may do some better optimization of binary code
generation if it knows that a variable is 'final' and will never
change.

...


On Jan 28, 4:53 am, Tim Russell <[email protected]> wrote:
> I've seen a lot of use of final for local primitives.
>
> Presumable to indicate to the compiler that the value shouldn't be changed.
>
> However, what's the implication of this on Dalvik?
>
> I believe final local variables are usually placed on the heap for extended
> lifetime (for use in inner classes), so is their a runtime overhead rather
> than using simple locals (which use Dalvik registers)?
>
> Thanks,
>  Tim

-- 
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

Reply via email to