From bff55f297a5c1f61add01419da9671cfea908c46 Mon Sep 17 00:00:00 2001 From: Alex Blewitt Date: Wed, 16 Mar 2016 01:30:35 +0000 Subject: Bug 489706 - Replace new Integer() with Integer.valueOf() There are a lot of new Integer() calls in the P2 codebase, which results in many duplicate values of Integer being stored, particularly when performing updates or checks. Integer.valueOf() performs this caching already, which means that it's unnecessary to call new Integer() and instead can call Integer.valueOf(). In the places where the int value is being used directly, the call can be further optimised to Integer.parseInt() instead. Replace calls to new Integer() with Integer.valueOf() or .parseInt() as appropriate. Change-Id: Ic760e66084c856fc90cb7c8a358007c975213638 Signed-off-by: Alex Blewitt --- .../equinox/internal/p2/importexport/persistence/P2FParser.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bundles/org.eclipse.equinox.p2.ui.importexport') diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser.java index bf0743fe8..fc755e86d 100644 --- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser.java +++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 WindRiver Corporation and others. + * Copyright (c) 2011, 2016 WindRiver Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -65,7 +65,7 @@ public class P2FParser extends XMLParser implements P2FConstants { public RepositoriesHandler(AbstractHandler parentHandler, Attributes attributes) { super(parentHandler, REPOSITORIES_ELEMENT); String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE); - uris = (size == null) ? new ArrayList() : new ArrayList(new Integer(size).intValue()); + uris = (size == null) ? new ArrayList() : new ArrayList(Integer.parseInt(size)); } @Override @@ -124,7 +124,7 @@ public class P2FParser extends XMLParser implements P2FConstants { public IUsHandler(ContentHandler parentHandler, Attributes attributes) { super(parentHandler, IUS_ELEMENT); String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE); - ius = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList()); + ius = (size != null ? new ArrayList(Integer.parseInt(size)) : new ArrayList()); } @Override -- cgit v1.2.3