diff options
| author | Laurent Redor | 2015-01-16 12:29:04 +0000 |
|---|---|---|
| committer | Laurent Redor | 2015-01-22 17:37:38 +0000 |
| commit | 77b493e64da3eab35c36daab9092b5702fee1457 (patch) | |
| tree | a83c194a3acc0157722d746cf149ae87afd3d495 | |
| parent | 7e115ca26ca2ada4f6e298cb627b066189a533b1 (diff) | |
| download | org.eclipse.sirius-77b493e64da3eab35c36daab9092b5702fee1457.tar.gz org.eclipse.sirius-77b493e64da3eab35c36daab9092b5702fee1457.tar.xz org.eclipse.sirius-77b493e64da3eab35c36daab9092b5702fee1457.zip | |
[457678] Minimize calls to getVerticalRange
Can be costly in some implementation, CDO Native for example
Bug: 457678
Change-Id: Ib48116e8dfc00d0e51e4391a60b00056111b56e3
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
3 files changed, 20 insertions, 18 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/FrameCreationValidator.java b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/FrameCreationValidator.java index da7deaa206..bdb01ec027 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/FrameCreationValidator.java +++ b/plugins/org.eclipse.sirius.diagram.sequence.ui/src/org/eclipse/sirius/diagram/sequence/ui/tool/internal/edit/validator/FrameCreationValidator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 THALES GLOBAL SERVICES. + * Copyright (c) 2011, 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 @@ -160,8 +160,9 @@ public class FrameCreationValidator extends AbstractSequenceInteractionValidator SortedSet<ISequenceEvent> overlapped = Sets.newTreeSet(new RangeComparator()); overlapped.addAll(sequenceEventsInCreationRange.values()); for (ISequenceEvent ise : Iterables.filter(overlapped, Predicates.not(Predicates.in(localParents)))) { - if (ise.getVerticalRange().getLowerBound() >= creationRange.getLowerBound()) { - Range newExpansionZone = new Range(ise.getVerticalRange().getLowerBound() - 1, creationRange.getUpperBound()); + int lowerBound = ise.getVerticalRange().getLowerBound(); + if (lowerBound >= creationRange.getLowerBound()) { + Range newExpansionZone = new Range(lowerBound - 1, creationRange.getUpperBound()); expansionZone = expansionZone.union(newExpansionZone); break; } diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractFrame.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractFrame.java index 6299e64894..cd7d53b9e8 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractFrame.java +++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/AbstractFrame.java @@ -141,8 +141,9 @@ public abstract class AbstractFrame extends AbstractSequenceNode implements ISeq for (Lifeline lifeline : coveredLifelines) { EventFinder finder = new EventFinder(lifeline); finder.setEventsToIgnore(Predicates.equalTo((ISequenceEvent) this)); - ISequenceEvent localParent = finder.findMostSpecificEvent(this.getVerticalRange()); - if (localParent != null && localParent.getVerticalRange().includes(this.getVerticalRange())) { + Range verticalRange = this.getVerticalRange(); + ISequenceEvent localParent = finder.findMostSpecificEvent(verticalRange); + if (localParent != null && localParent.getVerticalRange().includes(verticalRange)) { parentEvents.add(localParent); } } diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java index 6181cce14e..310f92fe4b 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java +++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 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 @@ -114,8 +114,7 @@ public class Message extends AbstractSequenceElement implements ISequenceEvent { } /** - * Predicate to check whether a Sirius DDiagramElement represents a - * message. + * Predicate to check whether a Sirius DDiagramElement represents a message. */ private static enum SiriusElementPredicate implements Predicate<DDiagramElement> { INSTANCE; @@ -146,11 +145,11 @@ public class Message extends AbstractSequenceElement implements ISequenceEvent { } /** - * Returns a predicate to check whether a Sirius DDiagramElement - * represents a message. + * Returns a predicate to check whether a Sirius DDiagramElement represents + * a message. * - * @return a predicate to check whether a Sirius DDiagramElement - * represents a message. + * @return a predicate to check whether a Sirius DDiagramElement represents + * a message. */ public static Predicate<DDiagramElement> viewpointElementPredicate() { return SiriusElementPredicate.INSTANCE; @@ -293,10 +292,10 @@ public class Message extends AbstractSequenceElement implements ISequenceEvent { */ public Rectangle getProperLogicalBounds() { Range range = getVerticalRange(); - + ISequenceNode srcElement = getSourceElement(); ISequenceNode tgtElement = getTargetElement(); - + Rectangle srcLogicalBounds = srcElement.getProperLogicalBounds().getCopy(); Rectangle tgtLogicalBounds = tgtElement.getProperLogicalBounds().getCopy(); @@ -315,11 +314,11 @@ public class Message extends AbstractSequenceElement implements ISequenceEvent { srcX = srcLogicalBounds.getLeft().x; tgtX = tgtLogicalBounds.getRight().x; } - + if (srcElement instanceof Lifeline) { srcX = srcLogicalBounds.getCenter().x; } - + if (tgtElement instanceof Lifeline) { tgtX = tgtLogicalBounds.getCenter().x; } @@ -401,14 +400,15 @@ public class Message extends AbstractSequenceElement implements ISequenceEvent { public Option<Operand> getParentOperand() { Option<Lifeline> sourceLifeline = getSourceLifeline(); Option<Operand> sourceParentOperand = Options.newNone(); + Range verticalRange = getVerticalRange(); if (sourceLifeline.some()) { - sourceParentOperand = sourceLifeline.get().getParentOperand(getVerticalRange()); + sourceParentOperand = sourceLifeline.get().getParentOperand(verticalRange); } Option<Lifeline> targetLifeline = getTargetLifeline(); Option<Operand> targetParentOperand = Options.newNone(); if (targetLifeline.some()) { - targetParentOperand = targetLifeline.get().getParentOperand(getVerticalRange()); + targetParentOperand = targetLifeline.get().getParentOperand(verticalRange); } boolean noOperand = !sourceParentOperand.some() && !targetParentOperand.some(); |
