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 --- .../p2/artifact/repository/CompositeArtifactRepository.java | 4 ++-- .../p2/artifact/repository/simple/SimpleArtifactRepository.java | 4 ++-- .../p2/artifact/repository/simple/SimpleArtifactRepositoryIO.java | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository') diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java index 018ce3ac0..5d63e9780 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/CompositeArtifactRepository.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2015 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM 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 @@ -33,7 +33,7 @@ import org.eclipse.osgi.util.NLS; public class CompositeArtifactRepository extends AbstractArtifactRepository implements ICompositeRepository { static final public String REPOSITORY_TYPE = CompositeArtifactRepository.class.getName(); - static final private Integer REPOSITORY_VERSION = new Integer(1); + static final private Integer REPOSITORY_VERSION = 1; static final public String XML_EXTENSION = ".xml"; //$NON-NLS-1$ static final public String JAR_EXTENSION = ".jar"; //$NON-NLS-1$ static final public String CONTENT_FILENAME = "compositeArtifacts"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java index 308419a91..b9bf5864a 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 IBM Corporation and others. + * Copyright (c) 2007, 2016 IBM 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 @@ -233,7 +233,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme private static final String JAR_EXTENSION = ".jar"; //$NON-NLS-1$ static final private String REPOSITORY_TYPE = IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY; - static final private Integer REPOSITORY_VERSION = new Integer(1); + static final private Integer REPOSITORY_VERSION = 1; private static final String XML_EXTENSION = ".xml"; //$NON-NLS-1$ protected Set artifactDescriptors = new HashSet(); /** diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryIO.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryIO.java index 9208cb3f3..ff7e45fa1 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryIO.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepositoryIO.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 IBM Corporation and others. + * Copyright (c) 2007, 2016 IBM 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 @@ -425,7 +425,7 @@ public class SimpleArtifactRepositoryIO { public MappingRulesHandler(AbstractHandler parentHandler, Attributes attributes) { super(parentHandler, MAPPING_RULES_ELEMENT); String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE); - mappingRules = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4)); + mappingRules = (size != null ? new ArrayList(Integer.parseInt(size)) : new ArrayList(4)); } public String[][] getMappingRules() { @@ -467,7 +467,7 @@ public class SimpleArtifactRepositoryIO { public ArtifactsHandler(AbstractHandler parentHandler, Attributes attributes) { super(parentHandler, ARTIFACTS_ELEMENT); String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE); - artifacts = (size != null ? new LinkedHashSet(new Integer(size).intValue()) : new LinkedHashSet(4)); + artifacts = (size != null ? new LinkedHashSet(Integer.parseInt(size)) : new LinkedHashSet(4)); } public Set getArtifacts() { @@ -550,7 +550,7 @@ public class SimpleArtifactRepositoryIO { public ProcessingStepsHandler(AbstractHandler parentHandler, Attributes attributes) { super(parentHandler, PROCESSING_STEPS_ELEMENT); String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE); - processingSteps = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4)); + processingSteps = (size != null ? new ArrayList(Integer.parseInt(size)) : new ArrayList(4)); } public IProcessingStepDescriptor[] getProcessingSteps() { -- cgit v1.2.3