From 0fa24bdc8e71d34653ba555eb5f4ba9708742ab4 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 19 Nov 2020 15:22:11 -0500 Subject: [PATCH] Performance: Redundant 'Collection.addAll()' call --- OsmAnd-java/src/main/java/com/google/protobuf/FieldSet.java | 3 +-- .../com/wdtinc/mapbox_vector_tile/adapt/jts/JtsAdapter.java | 3 +-- .../src/main/java/net/osmand/render/RenderingRulesStorage.java | 3 +-- OsmAnd/src/net/osmand/plus/TargetPointsHelper.java | 3 +-- OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java | 3 +-- OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java | 3 +-- OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java | 3 +-- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/OsmAnd-java/src/main/java/com/google/protobuf/FieldSet.java b/OsmAnd-java/src/main/java/com/google/protobuf/FieldSet.java index 2663694fc3..02ec66309e 100644 --- a/OsmAnd-java/src/main/java/com/google/protobuf/FieldSet.java +++ b/OsmAnd-java/src/main/java/com/google/protobuf/FieldSet.java @@ -242,8 +242,7 @@ final class FieldSet nextPolyGeom = new ArrayList<>(); boolean valid = true; // Add exterior ring @@ -362,7 +361,7 @@ public final class JtsAdapter { CoordinateArrays.reverse(exteriorRing.getCoordinates()); } - nextPolyGeom.addAll(linesToGeomCmds(exteriorRing, mvtClosePath, cursor, 2)); + final List nextPolyGeom = new ArrayList<>(linesToGeomCmds(exteriorRing, mvtClosePath, cursor, 2)); // Add interior rings diff --git a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java index 11ac95cbd5..cf97dd520c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java +++ b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStorage.java @@ -432,8 +432,7 @@ public class RenderingRulesStorage { for(RenderingRule ch : caseChildren) { List apply = applyRules; if(!renderingRule.getIfChildren().isEmpty()) { - apply = new ArrayList(); - apply.addAll(renderingRule.getIfChildren()); + apply = new ArrayList<>(renderingRule.getIfChildren()); if(applyRules != null) { apply.addAll(applyRules); } diff --git a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java index 01ee06e16f..4221ffa308 100644 --- a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java +++ b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java @@ -345,8 +345,7 @@ public class TargetPointsHelper { } public List getIntermediatePointsWithTarget() { - List res = new ArrayList<>(); - res.addAll(this.intermediatePoints); + List res = new ArrayList<>(this.intermediatePoints); if(pointToNavigate != null) { res.add(pointToNavigate); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index 1aa35b8589..9d8030f0a2 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -367,8 +367,7 @@ public class MenuBuilder { @Override public void onFinish(List cardList) { if (!isHidden()) { - List cards = new ArrayList<>(); - cards.addAll(cardList); + List cards = new ArrayList(cardList); if (cardList.size() == 0) { cards.add(new NoImagesCard(mapActivity)); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index ecdc776c78..fbf1ae9b96 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -427,8 +427,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { f.setArguments(args); f.show(getChildFragmentManager(), "exceedDialog"); } else if (TextUtils.isEmpty(poiTypeEditText.getText())) { - HashSet tagsCopy = new HashSet<>(); - tagsCopy.addAll(editPoiData.getTagValues().keySet()); + new HashSet<>(editPoiData.getTagValues().keySet()); if (Algorithms.isEmpty(editPoiData.getTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()))) { SaveExtraValidationDialogFragment f = new SaveExtraValidationDialogFragment(); Bundle args = new Bundle(); diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java index 93871dfca4..2e9e11c5c3 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiFiltersHelper.java @@ -231,9 +231,8 @@ public class PoiFiltersHelper { public List getTopDefinedPoiFilters(boolean includeDeleted) { List top = this.cacheTopStandardFilters; if (top == null) { - top = new ArrayList<>(); // user defined - top.addAll(getUserDefinedPoiFilters(true)); + top = new ArrayList<>(getUserDefinedPoiFilters(true)); // default MapPoiTypes poiTypes = application.getPoiTypes(); for (AbstractPoiType t : poiTypes.getTopVisibleFilters()) {