Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2017-11-29 14:05:31 +0000
committerGerrit Code Review @ Eclipse.org2017-11-29 14:05:31 +0000
commit1dfedf1ca0954907bcb125b0be9ad10870d43be4 (patch)
tree437df3b27b09f3b572793f08bc979d8d503e4733
parent798268e450dfb164c5339431fe1f4ba8adc2eb72 (diff)
parent74d17f2e25cce6329867ced58fa76ef2a8add08d (diff)
downloadorg.eclipse.papyrus-collaborativemodeling-1dfedf1ca0954907bcb125b0be9ad10870d43be4.tar.gz
org.eclipse.papyrus-collaborativemodeling-1dfedf1ca0954907bcb125b0be9ad10870d43be4.tar.xz
org.eclipse.papyrus-collaborativemodeling-1dfedf1ca0954907bcb125b0be9ad10870d43be4.zip
Merge "PapyrusDiagramPostComparison performs poorly"
-rw-r--r--plugins/compare/bundles/org.eclipse.papyrus.compare.diagram/src/org/eclipse/papyrus/compare/diagram/internal/PapyrusDiagramPostComparison.java35
1 files changed, 30 insertions, 5 deletions
diff --git a/plugins/compare/bundles/org.eclipse.papyrus.compare.diagram/src/org/eclipse/papyrus/compare/diagram/internal/PapyrusDiagramPostComparison.java b/plugins/compare/bundles/org.eclipse.papyrus.compare.diagram/src/org/eclipse/papyrus/compare/diagram/internal/PapyrusDiagramPostComparison.java
index 0e922509..d54db11d 100644
--- a/plugins/compare/bundles/org.eclipse.papyrus.compare.diagram/src/org/eclipse/papyrus/compare/diagram/internal/PapyrusDiagramPostComparison.java
+++ b/plugins/compare/bundles/org.eclipse.papyrus.compare.diagram/src/org/eclipse/papyrus/compare/diagram/internal/PapyrusDiagramPostComparison.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Obeo.
+ * Copyright (c) 2015, 2017 Obeo 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
@@ -7,14 +7,19 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - performance improvements
*******************************************************************************/
package org.eclipse.papyrus.compare.diagram.internal;
+import com.google.common.collect.LinkedHashMultimap;
+
+import java.util.List;
import java.util.Set;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.compare.merge.ResourceChangeAdapter;
import org.eclipse.emf.compare.merge.ResourceChangeAdapter.IResourceChangeParticipant;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -90,12 +95,32 @@ public class PapyrusDiagramPostComparison implements Runnable {
for (Object key : indexer.getEquivalentDiffsKeySet()) {
Set<Diff> diffs = indexer.getEquivalentDiffs(key);
if (diffs.size() > 1) {
- for (Diff diff : diffs) {
- for (Diff other : diffs) {
- if (other != diff && other.getSource() == diff.getSource()) {
- diff.getRequires().add(other);
+ // Keep a map of equivalent diffs based on having the same source.
+ LinkedHashMultimap<DifferenceSource, Diff> sourceDiffs = LinkedHashMultimap.create();
+ try {
+ for (Diff diff : diffs) {
+ sourceDiffs.put(diff.getSource(), diff);
+ // Turn off notification delivery because we can end up populating very large
+ // relations; processing all those notifications is unnecessary at this point in time,
+ // because the reference involved is bi-directional, cross referencers don't need to
+ // monitor it.
+ diff.eSetDeliver(false);
+ }
+
+ for (DifferenceSource differenceSource : sourceDiffs.keySet()) {
+ Set<Diff> equivalentDiffs = sourceDiffs.get(differenceSource);
+ for (Diff diff : equivalentDiffs) {
+ List<Diff> requires = diff.getRequires();
+ requires.addAll(equivalentDiffs);
+ // Remove the circular requirement.
+ requires.remove(diff);
}
}
+ } finally {
+ for (Diff diff : diffs) {
+ // Turn notification delivery back on after updating the requires references.
+ diff.eSetDeliver(true);
+ }
}
}
}

Back to the top