On 26/12/10 18:04, Soumya wrote:
Which will result in lesser memory usage and help in quicker garbage
collection.
Did you test it? I'm not that familiar with the java compiler, but I
know that gcc, for example, will easily pick up the fact that the
variable is not used beyond that point, and the optimizer will cause
both code styles to produce the same machine code. Since this stage of
the optimization is done by Sun's (now Oracle) java compiler, which is
quite a veteran, and not the dalvik post-processor, I will not be
surprised to hear that this is also the case here.
Meanwhile, you litter the source with code that is bordering on the
unreadable because you think it is more efficient, which helps neither
efficiency nor readability.
In general, the optimizer is there for you to be able to write readable,
maintainable code, without sacrificing performance. At least for C and
C++ with gcc, my personal recommendation is to not do these
micro-optimizations unless you can prove that:
A. They actually improve things
and
B. The improvement is worth the loss in maintainability.
Disclaimer: I am affiliated with neither Google nor Android, and cannot
speak on either of their behalf.
Shachar
--
Shachar Shemesh
Lingnu Open Source Consulting Ltd.
http://www.lingnu.com
--
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting