jsydow / swp-dv-ws2010-osm-1

Automatically exported from code.google.com/p/swp-dv-ws2010-osm-1
0 stars 0 forks source link

prefer the enhanced for loop #52

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In utils.DataNodeArrayItemizedOverlay.updateItem()

Use the more efficient extended for-loop (foreach) instead of the 
explicite,index-driven for-loop.

replace 

<code:java>
   for (int i = 0; i < overlayItems.size(); ++i)
                if (overlayItems.get(i).second.intValue() == id) {
                    OverlayItem oi = Helper.getOverlayItem(pos,
                            overlayItems.get(i).first.getMarker());
                    overlayItems.get(i).first = oi; // update the OverlayItem

</code>

with

<code:java>
  for ( Pair<OverlayItem,Integer> overlayItem : overlayItems) {
                if (overlayItem.second.intValue() == id) {
                    OverlayItem oi = Helper.getOverlayItem(pos,
                            overlayItem.first.getMarker());
                    overlayItem.first = oi; // update the OverlayItem
</code>

Original issue reported on code.google.com by jdswpdat on 21 Mar 2011 at 10:48

GoogleCodeExporter commented 9 years ago

Original comment by SakirS...@gmail.com on 21 Mar 2011 at 10:55

GoogleCodeExporter commented 9 years ago
Can you proove that the extended for-loop is really more efficient?

Original comment by thi...@inf.fu-berlin.de on 21 Mar 2011 at 4:55

GoogleCodeExporter commented 9 years ago

Original comment by benpi...@googlemail.com on 22 Mar 2011 at 11:29

GoogleCodeExporter commented 9 years ago

Original comment by benpi...@googlemail.com on 22 Mar 2011 at 4:37