From e3e578c98878b6e5bc8b9140389ffe36c5651b56 Mon Sep 17 00:00:00 2001 From: Alex Blewitt Date: Sun, 6 Sep 2015 17:13:21 +0100 Subject: Bug 476724 - Remove new Boolean and Boolean.valueOf().booleanValue() The new Boolean constructor creates a new instance of a Boolean object, but it can easily be replaced with Boolean.valueOf which returns the reference to the global Boolean.TRUE or Boolean.FALSE. Replace calls to new Boolean() with Boolean.valueOf() for identical semantics except without object collection. Additionally Boolean.valueOf().booleanValue() is identical to Boolean.parseBoolean() and will result in no garbage. In addition, methods will be (slightly) smaller and parseBoolean will often be in-lined by the JIT, which can often prove that the value is non-null for faster checking. Replace Boolean.valueOf().booleanValue() chains with Boolean.parseBoolean(). Some other tests can use Wrapper.valueOf() to take advantage of the built-in caches that these objects maintain (for values in the range -128..127). Signed-off-by: Alex Blewitt Change-Id: I5da4216a26ffbb6b8fd3365515ee800dd82b36ae --- .../src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bundles/org.eclipse.equinox.p2.director') diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java index 8f5780076..34566b09f 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2013 IBM Corporation and others. All rights reserved. This + * Copyright (c) 2007, 2015 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 http://www.eclipse.org/legal/epl-v10.html @@ -279,7 +279,7 @@ public class SimplePlanner implements IPlanner { } private static boolean hasHigherFidelity(IInstallableUnit iu, IInstallableUnit currentIU) { - if (Boolean.valueOf(currentIU.getProperty(IInstallableUnit.PROP_PARTIAL_IU)).booleanValue() && !Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_PARTIAL_IU)).booleanValue()) + if (Boolean.parseBoolean(currentIU.getProperty(IInstallableUnit.PROP_PARTIAL_IU)) && !Boolean.parseBoolean(iu.getProperty(IInstallableUnit.PROP_PARTIAL_IU))) return true; return false; } -- cgit v1.2.3