aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2011-09-29 15:21:50 (EDT)
committerOleg Besedin2011-09-29 15:21:50 (EDT)
commit16334e911487b3ea6c2d0a941fcd79faad8363ab (patch)
tree587c8b67247322fe6f63183d96b8e78c67590ffb
parentb9f758ea70fc19eb822897008912fb8ec7b9e707 (diff)
downloadeclipse.platform.runtime-16334e911487b3ea6c2d0a941fcd79faad8363ab.zip
eclipse.platform.runtime-16334e911487b3ea6c2d0a941fcd79faad8363ab.tar.gz
eclipse.platform.runtime-16334e911487b3ea6c2d0a941fcd79faad8363ab.tar.bz2
Bug 358658 - Roughly 40% of the heap being eaten by EclipseContextsv20110929-1921
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextChangeEvent.java6
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java2
-rw-r--r--bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ValueComputation.java12
3 files changed, 14 insertions, 6 deletions
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextChangeEvent.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextChangeEvent.java
index e88f368..69ebfae 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextChangeEvent.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ContextChangeEvent.java
@@ -67,6 +67,12 @@ public final class ContextChangeEvent {
*/
public static final int UPDATE = 5;
+ /**
+ * A change event type (value "6"), indicating that stored computations depending
+ * on a given name might need to be updated.
+ */
+ public static final int RECALC = 6;
+
private Object[] args;
private IEclipseContext context;
private int eventType;
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java
index 05a5113..2c270d1 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/EclipseContext.java
@@ -309,7 +309,7 @@ public class EclipseContext implements IEclipseContext {
* computations and listeners that depend on this name.
*/
public void invalidate(String name, int eventType, Object oldValue, Set<Scheduled> scheduled) {
- ContextChangeEvent event = new ContextChangeEvent(this, ContextChangeEvent.ADDED, null, name, oldValue);
+ ContextChangeEvent event = new ContextChangeEvent(this, eventType, null, name, oldValue);
ValueComputation computation = localValueComputations.get(name);
if (computation != null && computation.isValid()) {
computation.handleInvalid(event, scheduled);
diff --git a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ValueComputation.java b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ValueComputation.java
index 1bba081..aa700cc 100644
--- a/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ValueComputation.java
+++ b/bundles/org.eclipse.e4.core.contexts/src/org/eclipse/e4/core/internal/contexts/ValueComputation.java
@@ -34,13 +34,15 @@ public class ValueComputation extends Computation {
}
public void handleInvalid(ContextChangeEvent event, Set<Scheduled> scheduled) {
- cachedValue = NotAValue;
-
- if (name.equals(event.getName()))
+ int eventType = event.getEventType();
+ if (eventType != ContextChangeEvent.RECALC && name.equals(event.getName()))
invalidateComputation();
- int eventType = event.getEventType();
- originatingContext.invalidate(name, eventType == ContextChangeEvent.DISPOSE ? ContextChangeEvent.REMOVED : eventType, event.getOldValue(), scheduled);
+ if (cachedValue == NotAValue) // already invalidated
+ return;
+
+ cachedValue = NotAValue;
+ originatingContext.invalidate(name, eventType == ContextChangeEvent.DISPOSE ? ContextChangeEvent.REMOVED : ContextChangeEvent.RECALC, event.getOldValue(), scheduled);
}
public Object get() {