From 17b0b997ebc078c5a867a98c7db0a84c17f20798 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 19 Nov 2020 15:15:19 -0500 Subject: [PATCH] Performance: Bulk operation can be used instead of iteration --- .../src/main/java/net/osmand/binary/CachedOsmandIndexes.java | 4 +--- OsmAnd/src/net/osmand/plus/TargetPointsHelper.java | 4 +--- .../plus/activities/search/SearchPoiFilterFragment.java | 4 +--- OsmAnd/src/net/osmand/plus/development/LogcatActivity.java | 5 ++--- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java b/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java index 4a4bec70a2..63c81d13fa 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/CachedOsmandIndexes.java @@ -241,9 +241,7 @@ public class CachedOsmandIndexes { cblock.type = mr.getType(); mi.cities.add(cblock); } - for(String s : index.getAdditionalTagsList()) { - mi.attributeTagsTable.add(s); - } + mi.attributeTagsTable.addAll(index.getAdditionalTagsList()); reader.addressIndexes.add(mi); reader.indexes.add(mi); } diff --git a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java index 07ef8df985..01ee06e16f 100644 --- a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java +++ b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java @@ -309,9 +309,7 @@ public class TargetPointsHelper { public List getIntermediatePointsNavigation() { List intermediatePoints = new ArrayList<>(); if (settings.USE_INTERMEDIATE_POINTS_NAVIGATION.get()) { - for (TargetPoint t : this.intermediatePoints) { - intermediatePoints.add(t); - } + intermediatePoints.addAll(this.intermediatePoints); } return intermediatePoints; } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java index a1c4d466e1..6b3de30970 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java @@ -166,9 +166,7 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc } }); - for (AbstractPoiType p : res) { - filters.add(p); - } + filters.addAll(res); filters.add(poiFilters.getSearchByNamePOIFilter()); if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) { filters.add(poiFilters.getNominatimPOIFilter()); diff --git a/OsmAnd/src/net/osmand/plus/development/LogcatActivity.java b/OsmAnd/src/net/osmand/plus/development/LogcatActivity.java index 20f5c4ba4a..af0f6bbbfd 100644 --- a/OsmAnd/src/net/osmand/plus/development/LogcatActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/LogcatActivity.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.lang.ref.WeakReference; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -298,9 +299,7 @@ public class LogcatActivity extends ActionBarProgressActivity { LogcatActivity activity = logcatActivity.get(); if (activity != null) { boolean autoscroll = !activity.recyclerView.canScrollVertically(1); - for(String s : values) { - activity.logs.add(s); - } + activity.logs.addAll(Arrays.asList(values)); activity.adapter.notifyDataSetChanged(); if(autoscroll) { activity.recyclerView.scrollToPosition(activity.logs.size() - 1);