Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2015-01-16 12:29:59 +0000
committerLaurent Redor2015-01-22 17:37:45 +0000
commit5f0d5e70add735c07022db7a3ac0c934a408c5d0 (patch)
tree4f09fb562efd0aa75d2192b97f6e752e861bfa22
parent77b493e64da3eab35c36daab9092b5702fee1457 (diff)
downloadorg.eclipse.sirius-5f0d5e70add735c07022db7a3ac0c934a408c5d0.tar.gz
org.eclipse.sirius-5f0d5e70add735c07022db7a3ac0c934a408c5d0.tar.xz
org.eclipse.sirius-5f0d5e70add735c07022db7a3ac0c934a408c5d0.zip
[457678] Improve ParentOperandFinder.getParentOperand(Range)
* Change predicates order to improve perf: The order of Predicates have been changed in this method. The second was more costly than the first one. * Improve the coveredLifeline predicate by reducing the number of calls to CombinedFragment.computeCoveredLifelines(). Bug: 457678 Change-Id: Id501c928e3f8d003f120ae5e1343d44c8ba22213 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/util/ParentOperandFinder.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/util/ParentOperandFinder.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/util/ParentOperandFinder.java
index 9c9b41304c..cdc346af01 100644
--- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/util/ParentOperandFinder.java
+++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/util/ParentOperandFinder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES.
* 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
@@ -12,6 +12,7 @@ package org.eclipse.sirius.diagram.sequence.business.internal.util;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Map;
import java.util.Set;
import org.eclipse.sirius.diagram.sequence.business.internal.elements.AbstractNodeEvent;
@@ -33,6 +34,7 @@ import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
/**
* .
@@ -106,11 +108,20 @@ public final class ParentOperandFinder {
public Option<Operand> getParentOperand(final Range verticalRange) {
SequenceDiagram diagram = event.getDiagram();
Set<Operand> allOperands = diagram.getAllOperands();
+ // Map to store the result of the covered lifelines of a
+ // CombinedFragment to avoid to make this call for each Operand of the
+ // same CombinedFragment.
+ final Map<CombinedFragment, Collection<Lifeline>> combinedFragmentToCoveredLifelines = Maps.newHashMap();
Predicate<Operand> coveredLifeline = new Predicate<Operand>() {
// Filter the operands that cover the execution parent lifeline
public boolean apply(Operand input) {
- Collection<Lifeline> computeCoveredLifelines = input.computeCoveredLifelines();
+ CombinedFragment parentCombinedFragment = input.getCombinedFragment();
+ Collection<Lifeline> computeCoveredLifelines = combinedFragmentToCoveredLifelines.get(parentCombinedFragment);
+ if (computeCoveredLifelines == null) {
+ computeCoveredLifelines = parentCombinedFragment.computeCoveredLifelines();
+ combinedFragmentToCoveredLifelines.put(parentCombinedFragment, computeCoveredLifelines);
+ }
return computeCoveredLifelines != null && computeCoveredLifelines.contains(event.getLifeline().get());
}
};
@@ -125,8 +136,7 @@ public final class ParentOperandFinder {
};
Operand deepestCoveringOperand = null;
-
- for (Operand operand : Iterables.filter(allOperands, Predicates.and(coveredLifeline, includingExecutionRange))) {
+ for (Operand operand : Iterables.filter(allOperands, Predicates.and(includingExecutionRange, coveredLifeline))) {
// Find the deepest operand among the filtered ones
if (deepestCoveringOperand == null || rangeFunction.apply(deepestCoveringOperand).includes(rangeFunction.apply(operand))) {
deepestCoveringOperand = operand;

Back to the top