Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2015-09-06 16:13:21 +0000
committerAlex Blewitt2015-09-07 21:49:13 +0000
commite3e578c98878b6e5bc8b9140389ffe36c5651b56 (patch)
tree6c22e2cf834d3c6a267611f2d59b9d1c45511c90 /bundles/org.eclipse.equinox.p2.director.app
parent4c1b71edc5f460ce4dc183f592449b24dbe53c97 (diff)
downloadrt.equinox.p2-e3e578c98878b6e5bc8b9140389ffe36c5651b56.tar.gz
rt.equinox.p2-e3e578c98878b6e5bc8b9140389ffe36c5651b56.tar.xz
rt.equinox.p2-e3e578c98878b6e5bc8b9140389ffe36c5651b56.zip
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 <alex.blewitt@gmail.com> Change-Id: I5da4216a26ffbb6b8fd3365515ee800dd82b36ae
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.director.app')
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src_ant/org/eclipse/equinox/p2/director/app/ant/DirectorTask.java6
2 files changed, 6 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
index 891ff3ba0..1d077beaf 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
@@ -780,7 +780,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
Collection<IInstallableUnit> uninstalls = collectRoots(profile, rootsToUninstall, false);
// keep this result status in case there is a problem so we can report it to the user
- boolean wasRoaming = Boolean.valueOf(profile.getProperty(IProfile.PROP_ROAMING)).booleanValue();
+ boolean wasRoaming = Boolean.parseBoolean(profile.getProperty(IProfile.PROP_ROAMING));
try {
updateRoamingProperties(profile);
ProvisioningContext context = new ProvisioningContext(targetAgent);
@@ -793,7 +793,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
planAndExecute(profile, context, request);
} finally {
// if we were originally were set to be roaming and we changed it, change it back before we return
- if (wasRoaming && !Boolean.valueOf(profile.getProperty(IProfile.PROP_ROAMING)).booleanValue())
+ if (wasRoaming && !Boolean.parseBoolean(profile.getProperty(IProfile.PROP_ROAMING)))
setRoaming(profile);
}
}
@@ -1318,7 +1318,7 @@ public class DirectorApplication implements IApplication, ProvisioningListener {
throw new ProvisionException(Messages.Missing_profileid);
// make sure that we are set to be roaming before we update the values
- if (!Boolean.valueOf(profile.getProperty(IProfile.PROP_ROAMING)).booleanValue())
+ if (!Boolean.parseBoolean(profile.getProperty(IProfile.PROP_ROAMING)))
return;
ProfileChangeRequest request = new ProfileChangeRequest(profile);
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src_ant/org/eclipse/equinox/p2/director/app/ant/DirectorTask.java b/bundles/org.eclipse.equinox.p2.director.app/src_ant/org/eclipse/equinox/p2/director/app/ant/DirectorTask.java
index a753b225f..d2c5aeadd 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src_ant/org/eclipse/equinox/p2/director/app/ant/DirectorTask.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src_ant/org/eclipse/equinox/p2/director/app/ant/DirectorTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * 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
@@ -196,7 +196,7 @@ public class DirectorTask extends Task implements ILog {
public void setList(String value) {
if (value != null && value.length() > 0 && !value.startsWith(ANT_PREFIX))
- list = Boolean.valueOf(value).booleanValue();
+ list = Boolean.parseBoolean(value);
}
public void setMetadataRepository(String value) {
@@ -231,7 +231,7 @@ public class DirectorTask extends Task implements ILog {
public void setRoaming(String value) {
if (value != null && value.length() > 0 && !value.startsWith(ANT_PREFIX))
- roaming = Boolean.valueOf(value).booleanValue();
+ roaming = Boolean.parseBoolean(value);
}
public void setUninstallIU(String value) {

Back to the top