ArrayList loop performance in ART (Runtime Runtime for Android)

I read the performance recommendations here: http://developer.android.com/training/articles/perf-tips.html#Loops and at that time it looks like

for(i=0; i <= objectArrayList.size() ; ++i){}
Hinges

preferable for performance reasons for "for every" or "enhanced" style.

for(Object object : objectArrayList){}

Does this persist for ART or will it make a difference? Just wondering.

+4
source share
2 answers

Not an Android guru :)

It seems to me a premature optimization. But you have the right question. Cm

 for(i=0; i <= objectArrayList.size() ; ++i){
       Object o = objectArrayList.get(i);
       /// do stuff
    }

, , .

for(Object object : objectArrayList){
  // do stuff
}

Uses iterator for. .

for-each - , jvm ;)

+1

Dalvik ART , . Dalvik - JIT (Just-in-Time), ART - AOT (). . , , , .

ArrayList , . .

, Android-, . , , android K, ​​ .

+1

All Articles