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 /core/org.eclipse.cdt.core/model | |
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 'core/org.eclipse.cdt.core/model')
8 files changed, 17 insertions, 17 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java index c50bb1409c5..409a7a0e35e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2014 Intel Corporation and others. + * Copyright (c) 2007, 2016 Intel 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 @@ -99,7 +99,7 @@ public class CDataUtil { } public static String genId(String baseId) { - String suffix = new Integer(genRandomNumber()).toString(); + String suffix = Integer.toString(genRandomNumber()); return baseId != null ? new StringBuilder(baseId).append(".").append(suffix).toString() : //$NON-NLS-1$ suffix; @@ -1131,7 +1131,7 @@ public class CDataUtil { } public static void setInteger(ICStorageElement el, String attr, int value) { - el.setAttribute(attr, new Integer(value).toString()); + el.setAttribute(attr, Integer.toString(value)); } public static ICExclusionPatternPathEntry addRemoveExclusionsToEntry(ICExclusionPatternPathEntry entry, IPath[] paths, boolean add) throws IllegalArgumentException{ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java index f13caaaaaf3..86f1d79f61e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/SettingsSet.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2013 Intel Corporation and others. + * Copyright (c) 2007, 2016 Intel 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 @@ -376,7 +376,7 @@ public class SettingsSet { for (EntryInfo info : level.getInfos()) { EntryNameKey key = info.getContentsKey(); if (!map.containsKey(key)) - map.put(key, new Object[]{new Integer(l), info.getEntry()}); + map.put(key, new Object[]{Integer.valueOf(l), info.getEntry()}); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java index f6a930376f6..28896549900 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTCache.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2007, 2016 Wind River Systems, Inc. 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 @@ -36,7 +36,7 @@ public class ASTCache { /** * Tells whether this class is in debug mode. */ - private static final boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.cdt.core/debug/ASTCache")); //$NON-NLS-1$//$NON-NLS-2$ + private static final boolean DEBUG= Boolean.parseBoolean(Platform.getDebugOption("org.eclipse.cdt.core/debug/ASTCache")); //$NON-NLS-1$ private static final String DEBUG_PREFIX= "[ASTCache] "; //$NON-NLS-1$ /** Fast parse mode (use PDOM) */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java index 7816d5657d5..241f1f0eb67 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 QNX Software Systems and others. + * Copyright (c) 2000, 2016 QNX Software 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 diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java index b97e0d3dca5..cdc00259e5c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 QNX Software Systems and others. + * Copyright (c) 2000, 2016 QNX Software 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 @@ -570,7 +570,7 @@ public class PathEntryUtil { try { IMarker marker = project.createMarker(ICModelMarker.PATHENTRY_PROBLEM_MARKER); marker.setAttributes(new String[]{IMarker.MESSAGE, IMarker.SEVERITY, IMarker.LOCATION, - ICModelMarker.PATHENTRY_FILE_FORMAT,}, new Object[]{status.getMessage(), new Integer(severity), "pathentry",//$NON-NLS-1$ + ICModelMarker.PATHENTRY_FILE_FORMAT,}, new Object[]{status.getMessage(), Integer.valueOf(severity), "pathentry",//$NON-NLS-1$ "false",//$NON-NLS-1$ }); } catch (CoreException e) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java index 86bfac18507..095698b0a63 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2013 IBM Corporation and others. + * Copyright (c) 2002, 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 @@ -205,7 +205,7 @@ public class Util implements ICLogConstants { // Time stamp if (addTimeStamp) message = MessageFormat.format("[{0}] {1}", new Object[]{ //$NON-NLS-1$ - new Long(System.currentTimeMillis()), message}); + Long.valueOf(System.currentTimeMillis()), message}); while (message.length() > 100) { String partial = message.substring(0, 100); message = message.substring(100); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java index d0c3f2d5c4c..c08b68a6166 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CLanguageSetting.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Intel Corporation and others. + * Copyright (c) 2007, 2016 Intel 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 @@ -236,7 +236,7 @@ public class CLanguageSetting extends CDataProxy implements for(int i = 0; i < entries.length; i++){ ICLanguageSettingEntry entry = entries[i]; if(entry != null){ - Integer iKind = new Integer(entry.getKind()); + Integer iKind = Integer.valueOf(entry.getKind()); List[] addedRemovedListArr = (List[])map.get(iKind); if(addedRemovedListArr == null){ addedRemovedListArr = new List[2]; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java index f81c5f74dca..2a203285c8e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 Intel Corporation and others. + * Copyright (c) 2007, 2016 Intel 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 @@ -38,7 +38,7 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe fIsReadOnly = isReadOnly; if(el != null){ if(el.getAttribute(ATTR_CONFIG_RELATIONS) != null) - fConfigRelations = new Integer(CDataUtil.getInteger(el, ATTR_CONFIG_RELATIONS, DEFAULT_RELATIONS)); + fConfigRelations = Integer.valueOf(CDataUtil.getInteger(el, ATTR_CONFIG_RELATIONS, DEFAULT_RELATIONS)); } this.fSuperPreference = superPreference; @@ -77,7 +77,7 @@ public class CProjectDescriptionPreferences implements ICProjectDescriptionPrefe if(fConfigRelations != null && fConfigRelations.intValue() == status) return; - fConfigRelations = new Integer(status); + fConfigRelations = Integer.valueOf(status); fIsModified = true; } |