diff options
author | Marc-Andre Laperle | 2013-05-13 03:33:10 +0000 |
---|---|---|
committer | Marc-Andre Laperle | 2013-05-13 12:09:26 +0000 |
commit | a1f59f37087383e69d0f3c60435f758bc5a30c56 (patch) | |
tree | 81ca2a49c10a0db3fab31ba6e72c6942e93938a4 | |
parent | f70ab948fca7a1f8456092860eca560534f85602 (diff) | |
download | org.eclipse.cdt-a1f59f37087383e69d0f3c60435f758bc5a30c56.tar.gz org.eclipse.cdt-a1f59f37087383e69d0f3c60435f758bc5a30c56.tar.xz org.eclipse.cdt-a1f59f37087383e69d0f3c60435f758bc5a30c56.zip |
Bug 407483 - [performance] Performance improvements to decorators
On non-cdt projects, the decorators caused a ICProjectDescription to
be created every time a resource was decorated. The decorators should
only get the description when it already exists. Performance was also a
bit improved on cdt projects by extracting some variables out of a loop.
Change-Id: I125dc0ba55a72cfbd272fb6d6658474216021803
Reviewed-on: https://git.eclipse.org/r/12744
Reviewed-by: Andrew Gvozdev <angvoz.dev@gmail.com>
IP-Clean: Andrew Gvozdev <angvoz.dev@gmail.com>
Tested-by: Andrew Gvozdev <angvoz.dev@gmail.com>
2 files changed, 14 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java index e526a42d9e5..41a7d2ab31f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.ui.viewsupport; import java.util.List; +import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IResource; @@ -27,6 +28,7 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.internal.ui.CPluginImages; @@ -39,7 +41,8 @@ public class CustomBuildSettingsDecorator implements ILightweightLabelDecorator public void decorate(Object element, IDecoration decoration) { if (element instanceof IFile || element instanceof IFolder) { IResource rc = (IResource) element; - ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(rc.getProject(), false); + ICProjectDescriptionManager projectDescriptionManager = CoreModel.getDefault().getProjectDescriptionManager(); + ICProjectDescription prjDescription = projectDescriptionManager.getProjectDescription(rc.getProject(), ICProjectDescriptionManager.GET_IF_LOADDED); if (prjDescription != null) { ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); if (cfgDescription != null) { @@ -57,11 +60,13 @@ public class CustomBuildSettingsDecorator implements ILightweightLabelDecorator } if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + IContainer parent = rc.getParent(); + List<String> languages = LanguageSettingsManager.getLanguages(rc, cfgDescription); for (ILanguageSettingsProvider provider: ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()) { - for (String languageId : LanguageSettingsManager.getLanguages(rc, cfgDescription)) { + for (String languageId : languages) { List<ICLanguageSettingEntry> list = provider.getSettingEntries(cfgDescription, rc, languageId); if (list != null) { - List<ICLanguageSettingEntry> listDefault = provider.getSettingEntries(cfgDescription, rc.getParent(), languageId); + List<ICLanguageSettingEntry> listDefault = provider.getSettingEntries(cfgDescription, parent, languageId); // != is OK here due as the equal lists will have the same reference in WeakHashSet if (list != listDefault) return true; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java index 04068a0852c..b4427665d50 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Atmel Corporation and others. + * Copyright (c) 2010, 2013 Atmel 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 @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.viewsupport; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; import org.eclipse.jface.preference.JFacePreferences; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.IDecoration; @@ -38,20 +39,21 @@ public class ExcludedFileDecorator implements ILightweightLabelDecorator { if (element instanceof IFile || element instanceof IFolder) { IResource resource = (IResource) element; ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); - ICProjectDescription desc = mngr.getProjectDescription(resource.getProject(), false); + ICProjectDescription desc = mngr.getProjectDescription(resource.getProject(), ICProjectDescriptionManager.GET_IF_LOADDED); if (desc == null) return; ICConfigurationDescription conf = desc.getDefaultSettingConfiguration(); ICSourceEntry[] entries = conf.getSourceEntries(); boolean isUnderSourceRoot = false; + IPath fullPath = resource.getFullPath(); for (ICSourceEntry icSourceEntry : entries) { - if (icSourceEntry.getFullPath().isPrefixOf(resource.getFullPath())) { + if (icSourceEntry.getFullPath().isPrefixOf(fullPath)) { isUnderSourceRoot = true; break; } } // Only bother to mark items that would be included otherwise - if (isUnderSourceRoot && CDataUtil.isExcluded(resource.getFullPath(), entries)) { + if (isUnderSourceRoot && CDataUtil.isExcluded(fullPath, entries)) { decoration.addOverlay(CPluginImages.DESC_OVR_INACTIVE); decoration.setForegroundColor(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR)); } |