Be careful with 2) because of inlining. Can’t count the number of times I wrote benchmarks that got completely inlined away.
Hence the advice "Keep Things Monomorphic or Bimorphic" !
On hot paths, I often find it better to just avoid iterators in the first place than trying to clean up the mess later.
but from my own experience, you usually do not have to optimize that far, removing that 'synchronized' block, is far more common.
I'm not a pro of Android, so i wonder if the AOT system of Android (ART) has an option to provide a profile like you can do with gcc. It seems a better idea than to have to rewrite all the codes, third party codes included.
http://psy-lob-saw.blogspot.com.tr/2014/12/the-escape-of-arr...