aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Elder2013-01-15 12:26:09 (EST)
committerPaul Webster2013-01-15 13:07:05 (EST)
commit9a9ea5bd37a298580637db43d7c29502923ecdda (patch)
treefcd58291b49675857f9ff846c7462d70de3e7eb7
parent4be569edc122cfd835b7fc87faae3ae38d6c199b (diff)
downloadeclipse.platform.ui-9a9ea5bd37a298580637db43d7c29502923ecdda.zip
eclipse.platform.ui-9a9ea5bd37a298580637db43d7c29502923ecdda.tar.gz
eclipse.platform.ui-9a9ea5bd37a298580637db43d7c29502923ecdda.tar.bz2
Bug 389251 - [Performance] Idle Eclipse constantly allocates hundreds ofv20130115-180705
objects per second Don't continually create iterators or fire EMF notification events.
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java7
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java25
2 files changed, 25 insertions, 7 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java
index c0f314d..4cf7674 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java
@@ -213,8 +213,11 @@ public class HandledContributionItem extends ContributionItem {
if (updateRunner == null) {
updateRunner = new ISafeRunnable() {
public void run() throws Exception {
- model.setEnabled(canExecuteItem(null));
- update();
+ boolean shouldEnable = canExecuteItem(null);
+ if (shouldEnable != model.isEnabled()) {
+ model.setEnabled(shouldEnable);
+ update();
+ }
}
public void handleException(Throwable exception) {
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
index 1fbc751..b3e7316 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
@@ -1039,8 +1039,7 @@ public class PartRenderingEngine implements IPresentationEngine {
}
// Spin the event loop until someone disposes the display
while (((testShell != null && !testShell.isDisposed()) || (theApp != null
- && !theApp.getChildren().isEmpty() && someAreVisible(theApp
- .getChildren()))) && !display.isDisposed()) {
+ && someAreVisible(theApp.getChildren()))) && !display.isDisposed()) {
try {
if (!display.readAndDispatch()) {
runContext.processWaiting();
@@ -1079,9 +1078,25 @@ public class PartRenderingEngine implements IPresentationEngine {
}
protected boolean someAreVisible(List<MWindow> windows) {
- for (MWindow win : windows) {
- if (win.isToBeRendered() && win.isVisible()
- && win.getWidget() != null) {
+ // This method is called from the event dispatch loop, so the
+ // following optimization is in order...
+
+ // Ideally, we'd just do:
+ // for (MWindow win : theApp.getChildren()) {
+ // But this creates an iterator (which must be GC'd)
+ // at every call. The code below creates no objects.
+ final int limit = windows.size();
+ for (int i = 0; i < limit; i++) {
+ final MWindow win = windows.get(i);
+ // Note: Removed isVisible test, as this should have
+ // no impact on the whether the event loop
+ // terminates - non-visible windows still exists
+ // and can receive events.
+ // Note: isToBeRendered() == true => win.getWidget() != null
+ // but I'm not sure whether there is latency between setting
+ // toBeRendered and the creation of the widget. So, keeping
+ // both tests seems prudent.
+ if (win.isToBeRendered() && win.getWidget() != null) {
return true;
}
}