diff options
author | Alex Blewitt | 2016-04-15 22:41:51 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-04-16 16:17:48 +0000 |
commit | fc07efa909ea2702da76fe9842d258b96b4bc925 (patch) | |
tree | 7517debc7b91ae0d31e948c22b3a6a3c22638467 /lrparser | |
parent | 0b7b2a87d365db7620ce42f571733bb6453225ca (diff) | |
download | org.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 'lrparser')
2 files changed, 7 insertions, 7 deletions
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/symboltable/SymbolTableTests.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/symboltable/SymbolTableTests.java index 811a734bfa8..6b598bdaac4 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/symboltable/SymbolTableTests.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/symboltable/SymbolTableTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. + * Copyright (c) 2008, 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 @@ -36,7 +36,7 @@ public class SymbolTableTests {//extends TestCase { // a new symbol table was created assertFalse(st1.isEmpty()); - assertEquals(new Integer(1), st1.lookup(KEYS[0])); + assertEquals(Integer.valueOf(1), st1.lookup(KEYS[0])); FunctionalMap<String,Integer> st2 = st1.insert(KEYS[1], 2); FunctionalMap<String,Integer> st3 = st2.insert(KEYS[2], 3); @@ -95,8 +95,8 @@ public class SymbolTableTests {//extends TestCase { FunctionalMap<String,Integer> map2 = map1.insert(KEYS[5], 999); FunctionalMap<String,Integer> map3 = map2.insert(KEYS[5], null); - assertEquals(new Integer(5), map1.lookup(KEYS[5])); - assertEquals(new Integer(999), map2.lookup(KEYS[5])); + assertEquals(Integer.valueOf(5), map1.lookup(KEYS[5])); + assertEquals(Integer.valueOf(999), map2.lookup(KEYS[5])); assertNull(map3.lookup(KEYS[5])); } diff --git a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java index dd028e5e9ce..0a67e49d777 100644 --- a/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java +++ b/lrparser/org.eclipse.cdt.core.lrparser/src/org/eclipse/cdt/core/dom/lrparser/action/BuildASTParserAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 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 @@ -1021,7 +1021,7 @@ public abstract class BuildASTParserAction extends AbstractParserAction { private boolean discardInitializer(IASTExpression expression) { return initializerListNestingLevel > 0 - && "true".equals(properties.get(LRParserProperties.SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS)) //$NON-NLS-1$ + && Boolean.parseBoolean(properties.get(LRParserProperties.SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS)) && !ASTQueries.canContainName(expression); } @@ -1097,4 +1097,4 @@ public abstract class BuildASTParserAction extends AbstractParserAction { astStack.push(problemHolder); } -}
\ No newline at end of file +} |