Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2016-04-15 22:41:51 +0000
committerGerrit Code Review @ Eclipse.org2016-04-16 16:17:48 +0000
commitfc07efa909ea2702da76fe9842d258b96b4bc925 (patch)
tree7517debc7b91ae0d31e948c22b3a6a3c22638467 /dsf/org.eclipse.cdt.tests.dsf
parent0b7b2a87d365db7620ce42f571733bb6453225ca (diff)
downloadorg.eclipse.cdt-fc07efa909ea2702da76fe9842d258b96b4bc925.tar.gz
org.eclipse.cdt-fc07efa909ea2702da76fe9842d258b96b4bc925.tar.xz
org.eclipse.cdt-fc07efa909ea2702da76fe9842d258b96b4bc925.zip
Bug 491825 - Remove primitive wrapper creation
Using `new Integer` and other wrapper types such as `new Character` results in potential extra heap utilisation as the values are not cached. The built-in `Integer.valueOf` will perform caching on numbers in the range -128..127 (at least) using a flyweight pattern. In addition, parsing `int` values can be done with `Integer.parseInt` which avoids object construction. Adjust tests such as `"true".equals(expr)` to `Boolean.parseBoolean(expr)`. Change-Id: I0408a5c69afc4ca6ede71acaf6cc4abd67538006 Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
Diffstat (limited to 'dsf/org.eclipse.cdt.tests.dsf')
-rw-r--r--dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/ViewerUpdatesListener.java8
-rw-r--r--dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/breakpoints/DsfTestBreakpointAttributeTranslator2.java4
-rw-r--r--dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/DsfQueryTests.java4
3 files changed, 8 insertions, 8 deletions
diff --git a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/ViewerUpdatesListener.java b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/ViewerUpdatesListener.java
index f93c0b11b22..b89e34f3b1f 100644
--- a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/ViewerUpdatesListener.java
+++ b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/ViewerUpdatesListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2015 Wind River Systems and others.
+ * Copyright (c) 2009, 2016 Wind River Systems 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
@@ -197,13 +197,13 @@ public class ViewerUpdatesListener
childrenIndexes = new TreeSet<Integer>();
fChildrenUpdatesScheduled.put(path, childrenIndexes);
}
- childrenIndexes.add(new Integer(index));
+ childrenIndexes.add(index);
}
public void removeChildrenUpdate(TreePath path, int index) {
Set<Integer> childrenIndexes = fChildrenUpdatesScheduled.get(path);
if (childrenIndexes != null) {
- childrenIndexes.remove(new Integer(index));
+ childrenIndexes.remove(Integer.valueOf(index));
if (childrenIndexes.isEmpty()) {
fChildrenUpdatesScheduled.remove(path);
}
@@ -368,7 +368,7 @@ public class ViewerUpdatesListener
Set<Integer> childrenIndexes = fChildrenUpdatesScheduled.get(update.getElementPath());
if (childrenIndexes != null) {
for (int i = start; i < end; i++) {
- childrenIndexes.remove(new Integer(i));
+ childrenIndexes.remove(Integer.valueOf(i));
}
if (childrenIndexes.isEmpty()) {
fChildrenUpdatesScheduled.remove(update.getElementPath());
diff --git a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/breakpoints/DsfTestBreakpointAttributeTranslator2.java b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/breakpoints/DsfTestBreakpointAttributeTranslator2.java
index 7d182f69254..67af3a7da1d 100644
--- a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/breakpoints/DsfTestBreakpointAttributeTranslator2.java
+++ b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/breakpoints/DsfTestBreakpointAttributeTranslator2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2015 Wind River Systems and others.
+ * Copyright (c) 2008, 2016 Wind River Systems 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
@@ -48,7 +48,7 @@ public class DsfTestBreakpointAttributeTranslator2 implements IBreakpointAttribu
{
Integer num = (Integer)bpAttrs.get(DsfTestBreakpoint.ATTR_NUM_TARGET_BREAKPOINTS);
if (num == null) {
- num = new Integer(1);
+ num = 1;
}
List<Map<String, Object>> subBpsAttrs = new ArrayList<Map<String, Object>>(num);
for (int i = 0; i < num; i++) {
diff --git a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/DsfQueryTests.java b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/DsfQueryTests.java
index ebfc48e2d54..a8f0d74d0b9 100644
--- a/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/DsfQueryTests.java
+++ b/dsf/org.eclipse.cdt.tests.dsf/src/org/eclipse/cdt/tests/dsf/concurrent/DsfQueryTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2015 Wind River Systems and others.
+ * Copyright (c) 2006, 2016 Wind River Systems 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
@@ -265,7 +265,7 @@ public class DsfQueryTests {
// Complete rm and query.
@SuppressWarnings("unchecked")
DataRequestMonitor<Integer> drm = (DataRequestMonitor<Integer>)rmHolder[0];
- drm.setData(new Integer(1));
+ drm.setData(Integer.valueOf(1));
rmHolder[0].done();
// Try to retrieve data again, it should still result in

Back to the top