diff options
author | Alex Blewitt | 2016-03-22 17:29:14 +0000 |
---|---|---|
committer | Pascal Rapicault | 2016-04-27 22:20:14 +0000 |
commit | 8c638d0e02bfaf3d3c2f6ac06681a14d52d88916 (patch) | |
tree | 14b61d3cf0d7fcfc912f9fdcaa4db9b533731872 | |
parent | f64681eca06c4f8142bac7f0a1c91df8113a232d (diff) | |
download | rt.equinox.p2-8c638d0e02bfaf3d3c2f6ac06681a14d52d88916.tar.gz rt.equinox.p2-8c638d0e02bfaf3d3c2f6ac06681a14d52d88916.tar.xz rt.equinox.p2-8c638d0e02bfaf3d3c2f6ac06681a14d52d88916.zip |
Bug 489706 - Remove custom Integer cache from P2Y20160428-1430Y20160428-1000I20160504-0035I20160503-2000I20160502-2000I20160501-2000I20160430-2000I20160429-2300I20160429-2000I20160428-0800I20160427-2000
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>
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) { |