Performance: Redundant 'Collection.addAll()' call

This commit is contained in:
TacoTheDank 2020-11-19 15:22:11 -05:00
parent 6f60a6298c
commit 0fa24bdc8e
7 changed files with 7 additions and 14 deletions

View file

@ -242,8 +242,7 @@ final class FieldSet<FieldDescriptorType extends
// Wrap the contents in a new list so that the caller cannot change
// the list's contents after setting it.
final List newList = new ArrayList();
newList.addAll((List) value);
final List newList = new ArrayList((List) value);
for (final Object element : newList) {
verifyType(descriptor.getLiteType(), element);
}

View file

@ -345,7 +345,6 @@ public final class JtsAdapter {
for(int i = 0; i < geom.getNumGeometries(); ++i) {
final Polygon nextPoly = (Polygon) geom.getGeometryN(i);
final List<Integer> 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<Integer> nextPolyGeom = new ArrayList<>(linesToGeomCmds(exteriorRing, mvtClosePath, cursor, 2));
// Add interior rings

View file

@ -432,8 +432,7 @@ public class RenderingRulesStorage {
for(RenderingRule ch : caseChildren) {
List<RenderingRule> apply = applyRules;
if(!renderingRule.getIfChildren().isEmpty()) {
apply = new ArrayList<RenderingRule>();
apply.addAll(renderingRule.getIfChildren());
apply = new ArrayList<>(renderingRule.getIfChildren());
if(applyRules != null) {
apply.addAll(applyRules);
}

View file

@ -345,8 +345,7 @@ public class TargetPointsHelper {
}
public List<TargetPoint> getIntermediatePointsWithTarget() {
List<TargetPoint> res = new ArrayList<>();
res.addAll(this.intermediatePoints);
List<TargetPoint> res = new ArrayList<>(this.intermediatePoints);
if(pointToNavigate != null) {
res.add(pointToNavigate);
}

View file

@ -367,8 +367,7 @@ public class MenuBuilder {
@Override
public void onFinish(List<ImageCard> cardList) {
if (!isHidden()) {
List<AbstractCard> cards = new ArrayList<>();
cards.addAll(cardList);
List<AbstractCard> cards = new ArrayList<AbstractCard>(cardList);
if (cardList.size() == 0) {
cards.add(new NoImagesCard(mapActivity));
}

View file

@ -427,8 +427,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
f.setArguments(args);
f.show(getChildFragmentManager(), "exceedDialog");
} else if (TextUtils.isEmpty(poiTypeEditText.getText())) {
HashSet<String> 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();

View file

@ -231,9 +231,8 @@ public class PoiFiltersHelper {
public List<PoiUIFilter> getTopDefinedPoiFilters(boolean includeDeleted) {
List<PoiUIFilter> 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()) {