Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2016-04-19 10:35:21 +0000
committerGerrit Code Review @ Eclipse.org2016-04-19 17:35:54 +0000
commit2114f6b108763ff027fe0936e1f7b4d7e9cc655c (patch)
treeafd55872d8d3dae5de15300ef63cc6acffdc6e92 /core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt
parent10ba077124e266fb7cfa661241d044a3ee91e0d3 (diff)
downloadorg.eclipse.cdt-2114f6b108763ff027fe0936e1f7b4d7e9cc655c.tar.gz
org.eclipse.cdt-2114f6b108763ff027fe0936e1f7b4d7e9cc655c.tar.xz
org.eclipse.cdt-2114f6b108763ff027fe0936e1f7b4d7e9cc655c.zip
Bug 491984 - Replace .equals("") with .isEmpty()
In many cases a String's empty status is tested with `.equals("")`. However, Java 1.6 added `.isEmpty()` which can be more efficient since it compares the internal length parameter only for testing. Replace code using the `.isEmpty()` variant instead. Some tests for `"".equals(expr)` can be replaced with `expr.isEmpty()` where it is already known that the `expr` is not null; however, these have to be reviewed on a case-by-case basis. Change-Id: I3c6af4d8b7638e757435914ac76cb3a67899a5fd Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
Diffstat (limited to 'core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt')
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java4
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java4
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ConditionalProcessGroup.java4
3 files changed, 6 insertions, 6 deletions
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java
index 20a45520ce2..5f8af78a0f8 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/SharedDefaults.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * Copyright (c) 2007, 2016 Symbian Software Limited 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
@@ -135,7 +135,7 @@ public class SharedDefaults extends HashMap<String, String> {
Element xmlElement = sharedElementList.get(i);
key = xmlElement.getAttribute(TemplateEngineHelper.ID);
value = xmlElement.getAttribute(TemplateEngineHelper.VALUE);
- if (key != null && !key.trim().equals("")) { //$NON-NLS-1$
+ if (key != null && !key.trim().isEmpty()) {
sharedDefaultsMap.put(key, value);
}
}
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java
index 7e60e8dde4b..45e4c286213 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2014 Symbian Software Limited and others.
+ * Copyright (c) 2007, 2016 Symbian Software Limited 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
@@ -176,7 +176,7 @@ public class TemplateDescriptor {
Element propertyElement = children.get(i);
String key = propertyElement.getAttribute(ID);
String value = propertyElement.getAttribute(DEFAULT);
- if (key != null && !key.equals("")) { //$NON-NLS-1$
+ if (key != null && !key.isEmpty()) {
defaults.put(key, value);
}
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ConditionalProcessGroup.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ConditionalProcessGroup.java
index 56979cc7e76..c324ff3f0ad 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ConditionalProcessGroup.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ConditionalProcessGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2014 Symbian Software Limited and others.
+ * Copyright (c) 2007, 2016 Symbian Software Limited 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
@@ -75,7 +75,7 @@ public class ConditionalProcessGroup {
this.id = "Condition " + id; //$NON-NLS-1$
conditionString = conditionElement.getAttribute(ProcessHelper.CONDITION);
if (conditionString != null) {
- if (conditionString.trim().equals("")) { //$NON-NLS-1$
+ if (conditionString.trim().isEmpty()) {
conditionString = null;
} else {
int op = conditionString.indexOf(ProcessHelper.EQUALS);

Back to the top