Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2016-03-22 17:29:14 +0000
committerPascal Rapicault2016-04-27 22:20:14 +0000
commit8c638d0e02bfaf3d3c2f6ac06681a14d52d88916 (patch)
tree14b61d3cf0d7fcfc912f9fdcaa4db9b533731872 /bundles
parentf64681eca06c4f8142bac7f0a1c91df8113a232d (diff)
downloadrt.equinox.p2-8c638d0e02bfaf3d3c2f6ac06681a14d52d88916.tar.gz
rt.equinox.p2-8c638d0e02bfaf3d3c2f6ac06681a14d52d88916.tar.xz
rt.equinox.p2-8c638d0e02bfaf3d3c2f6ac06681a14d52d88916.zip
The OmniVersion provides a custom Integer cache, which apart from storing the MAX_VALUE has no additional benefit over and above using the built-in Integer cache. Replace calls to new Integer() with Integer.valueOf() Change-Id: Ibbcc0072a103bd16c7ef1e86a7962b9d88a5c1cb Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OmniVersion.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionParser.java19
2 files changed, 5 insertions, 18 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OmniVersion.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OmniVersion.java
index 5a8e349da..b5a6f6372 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OmniVersion.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/OmniVersion.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Cloudsmith Inc. and others.
+ * Copyright (c) 2009, 2016 Cloudsmith Inc. 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
@@ -62,7 +62,7 @@ public class OmniVersion extends BasicVersion {
if (padValue == VersionVector.MAX_VALUE)
return (BasicVersion) MAX_VERSION;
}
- if (vtop == 3 && padValue == null && vector.get(0) == VersionParser.ZERO_INT && vector.get(1) == VersionParser.ZERO_INT && vector.get(2) == VersionParser.ZERO_INT)
+ if (vtop == 3 && padValue == null && vector.get(0) == (Integer) 0 && vector.get(1) == (Integer) 0 && vector.get(2) == (Integer) 0)
return (BasicVersion) emptyVersion;
return new OmniVersion(vector, format, original);
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionParser.java
index 3b71bec6d..49fda092c 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionParser.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Cloudsmith Inc. and others.
+ * Copyright (c) 2009, 2016 Cloudsmith Inc. 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
@@ -24,23 +24,10 @@ import org.eclipse.osgi.util.NLS;
* @noextend This class is not intended to be subclassed by clients.
*/
public abstract class VersionParser {
- public static final Integer ZERO_INT = new Integer(0);
-
- public static final Integer MAX_INT_OBJ = new Integer(Integer.MAX_VALUE);
-
- private static final Integer cache[] = new Integer[100];
-
- static {
- cache[0] = ZERO_INT;
- for (int i = 1; i < cache.length; i++)
- cache[i] = new Integer(i);
- }
+ public static final Integer MAX_INT_OBJ = Integer.MAX_VALUE;
public static Integer valueOf(int i) {
- if (i >= 0 && i < cache.length)
- return cache[i];
-
- return (i == Integer.MAX_VALUE) ? MAX_INT_OBJ : new Integer(i);
+ return (i == Integer.MAX_VALUE) ? MAX_INT_OBJ : Integer.valueOf(i);
}
static Comparable<?> removeRedundantTrail(List<Comparable<?>> segments, Comparable<?> padValue) {

Back to the top