diff options
author | Alex Blewitt | 2016-03-16 01:30:35 +0000 |
---|---|---|
committer | Alex Blewitt | 2016-04-19 08:34:01 +0000 |
commit | bff55f297a5c1f61add01419da9671cfea908c46 (patch) | |
tree | c1438bc3be529485b3965a66c4a4cc1893d2320c /bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal | |
parent | 30aa50233fe07edc71b6729f7690454170215932 (diff) | |
download | rt.equinox.p2-bff55f297a5c1f61add01419da9671cfea908c46.tar.gz rt.equinox.p2-bff55f297a5c1f61add01419da9671cfea908c46.tar.xz rt.equinox.p2-bff55f297a5c1f61add01419da9671cfea908c46.zip |
Bug 489706 - Replace new Integer() with Integer.valueOf()I20160419-0800
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 <alex.blewitt@gmail.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal')
8 files changed, 36 insertions, 37 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java index bda16bc60..2a97d36d5 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/RequiredCapability.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 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 @@ -284,9 +284,9 @@ public class RequiredCapability implements IRequiredCapability, IMemberProvider if (MEMBER_FILTER == memberName) return filter; if (MEMBER_MIN == memberName) - return new Integer(min); + return Integer.valueOf(min); if (MEMBER_MAX == memberName) - return new Integer(max); + return Integer.valueOf(max); if (MEMBER_GREEDY == memberName) return Boolean.valueOf(greedy); if (MEMBER_MATCH == memberName) diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java index a53ddbd3a..19ce082ed 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.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 @@ -1189,11 +1189,11 @@ class VersionFormatParser { } private VersionFormatException formatException(String message) { - return new VersionFormatException(NLS.bind(Messages.syntax_error_in_version_format_0_1_2, new Object[] {format.substring(start, eos), new Integer(current), message})); + return new VersionFormatException(NLS.bind(Messages.syntax_error_in_version_format_0_1_2, new Object[] {format.substring(start, eos), Integer.valueOf(current), message})); } private VersionFormatException formatException(String found, String expected) { - return new VersionFormatException(NLS.bind(Messages.syntax_error_in_version_format_0_1_found_2_expected_3, new Object[] {format.substring(start, eos), new Integer(current), found, expected})); + return new VersionFormatException(NLS.bind(Messages.syntax_error_in_version_format_0_1_found_2_expected_3, new Object[] {format.substring(start, eos), Integer.valueOf(current), found, expected})); } private VersionFormatException illegalControlCharacter(char c) { @@ -1731,4 +1731,4 @@ class VersionFormatParser { sb.append(c); } } -}
\ No newline at end of file +} diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java index 6a017aea3..b1eb3185f 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/CoercingComparator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 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 @@ -132,7 +132,7 @@ public abstract class CoercingComparator<T> { if (v instanceof Integer) return (Integer) v; if (v instanceof Number) - return new Integer(((Number) v).intValue()); + return Integer.valueOf(((Number) v).intValue()); if (v instanceof String) { try { return Integer.valueOf(((String) v).trim()); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ExpressionFactory.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ExpressionFactory.java index cfa9e2c11..e2e262086 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ExpressionFactory.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ExpressionFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 Cloudsmith Inc. and others. + * Copyright (c) 2011, 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 @@ -190,7 +190,7 @@ public class ExpressionFactory implements IExpressionFactory, IExpressionConstan } public IExpression limit(IExpression collection, int count) { - return new Limit((Expression) collection, Literal.create(new Integer(count))); + return new Limit((Expression) collection, Literal.create(Integer.valueOf(count))); } public IExpression matches(IExpression lhs, IExpression rhs) { diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Limit.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Limit.java index 5a5a1e5f2..e60e6ed72 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Limit.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Limit.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 @@ -52,7 +52,7 @@ final class Limit extends Binary { } Limit(Expression operand, int limit) { - this(operand, (Expression) ExpressionFactory.INSTANCE.constant(new Integer(limit))); + this(operand, (Expression) ExpressionFactory.INSTANCE.constant(Integer.valueOf(limit))); } public Object evaluate(IEvaluationContext context) { diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Member.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Member.java index 59e82a0f2..15e8935f4 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Member.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Member.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 @@ -105,7 +105,6 @@ public abstract class Member extends Unary { } public static class LengthMember extends Member { - private static final Integer ZERO = new Integer(0); LengthMember(Expression operand) { super(operand, "length", Expression.emptyArray); //$NON-NLS-1$ @@ -113,7 +112,7 @@ public abstract class Member extends Unary { public Object evaluate(IEvaluationContext context) { int len = getLength(operand.evaluate(context)); - return len == 0 ? ZERO : new Integer(len); + return Integer.valueOf(len); } int getLength(Object val) { diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/ExpressionParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/ExpressionParser.java index f86a657a1..314cb7ad3 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/ExpressionParser.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/ExpressionParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Cloudsmith Inc. and others. + * Copyright (c) 2010, 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 @@ -60,11 +60,11 @@ public class ExpressionParser extends Stack<IExpression> implements IExpressionC protected static final Map<String, Integer> keywords; static { keywords = new HashMap<String, Integer>(); - keywords.put(KEYWORD_FALSE, new Integer(TOKEN_FALSE)); - keywords.put(KEYWORD_NULL, new Integer(TOKEN_NULL)); - keywords.put(KEYWORD_TRUE, new Integer(TOKEN_TRUE)); - keywords.put(KEYWORD_ALL, new Integer(TOKEN_ALL)); - keywords.put(KEYWORD_EXISTS, new Integer(TOKEN_EXISTS)); + keywords.put(KEYWORD_FALSE, Integer.valueOf(TOKEN_FALSE)); + keywords.put(KEYWORD_NULL, Integer.valueOf(TOKEN_NULL)); + keywords.put(KEYWORD_TRUE, Integer.valueOf(TOKEN_TRUE)); + keywords.put(KEYWORD_ALL, Integer.valueOf(TOKEN_ALL)); + keywords.put(KEYWORD_EXISTS, Integer.valueOf(TOKEN_EXISTS)); } protected final IExpressionFactory factory; diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/QLParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/QLParser.java index c3faf8eb5..54589384b 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/QLParser.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/parser/QLParser.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 @@ -35,20 +35,20 @@ public class QLParser extends ExpressionParser { static { qlKeywords = new HashMap<String, Integer>(); qlKeywords.putAll(keywords); - qlKeywords.put(KEYWORD_COLLECT, new Integer(TOKEN_COLLECT)); - qlKeywords.put(KEYWORD_FALSE, new Integer(TOKEN_FALSE)); - qlKeywords.put(KEYWORD_FIRST, new Integer(TOKEN_FIRST)); - qlKeywords.put(KEYWORD_FLATTEN, new Integer(TOKEN_FLATTEN)); - qlKeywords.put(KEYWORD_LATEST, new Integer(TOKEN_LATEST)); - qlKeywords.put(KEYWORD_LIMIT, new Integer(TOKEN_LIMIT)); - qlKeywords.put(KEYWORD_NULL, new Integer(TOKEN_NULL)); - qlKeywords.put(KEYWORD_SELECT, new Integer(TOKEN_SELECT)); - qlKeywords.put(KEYWORD_TRAVERSE, new Integer(TOKEN_TRAVERSE)); - qlKeywords.put(KEYWORD_TRUE, new Integer(TOKEN_TRUE)); - qlKeywords.put(KEYWORD_UNIQUE, new Integer(TOKEN_UNIQUE)); - qlKeywords.put(KEYWORD_INTERSECT, new Integer(TOKEN_INTERSECT)); - qlKeywords.put(KEYWORD_UNION, new Integer(TOKEN_UNION)); - qlKeywords.put(OPERATOR_EACH, new Integer(TOKEN_ANY)); + qlKeywords.put(KEYWORD_COLLECT, Integer.valueOf(TOKEN_COLLECT)); + qlKeywords.put(KEYWORD_FALSE, Integer.valueOf(TOKEN_FALSE)); + qlKeywords.put(KEYWORD_FIRST, Integer.valueOf(TOKEN_FIRST)); + qlKeywords.put(KEYWORD_FLATTEN, Integer.valueOf(TOKEN_FLATTEN)); + qlKeywords.put(KEYWORD_LATEST, Integer.valueOf(TOKEN_LATEST)); + qlKeywords.put(KEYWORD_LIMIT, Integer.valueOf(TOKEN_LIMIT)); + qlKeywords.put(KEYWORD_NULL, Integer.valueOf(TOKEN_NULL)); + qlKeywords.put(KEYWORD_SELECT, Integer.valueOf(TOKEN_SELECT)); + qlKeywords.put(KEYWORD_TRAVERSE, Integer.valueOf(TOKEN_TRAVERSE)); + qlKeywords.put(KEYWORD_TRUE, Integer.valueOf(TOKEN_TRUE)); + qlKeywords.put(KEYWORD_UNIQUE, Integer.valueOf(TOKEN_UNIQUE)); + qlKeywords.put(KEYWORD_INTERSECT, Integer.valueOf(TOKEN_INTERSECT)); + qlKeywords.put(KEYWORD_UNION, Integer.valueOf(TOKEN_UNION)); + qlKeywords.put(OPERATOR_EACH, Integer.valueOf(TOKEN_ANY)); } public QLParser(IExpressionFactory factory) { |