[542789] Optimize stereotype application handling in ElementImpl.eBasicSetContainer()
ElementImpl.eBasicSetContainer() calls ElementOperations.unapplyAllNonApplicableStereotypes(),
which can take very long for big models. It appears as if this call
isn't needed at all if the oldContainer is null.
Change-Id: Ifb64228768118b5aaf65f9e4f6c705492a93e3fe
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=542789
Signed-off-by: Eike Stepper <stepper@esc-net.de>
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/impl/ElementImpl.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/impl/ElementImpl.java
index f03d632..be6a6b1 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/impl/ElementImpl.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/impl/ElementImpl.java
@@ -895,11 +895,12 @@
public NotificationChain eBasicSetContainer(InternalEObject newContainer,
int newContainerFeatureID, NotificationChain msgs) {
+ InternalEObject oldContainer = eInternalContainer();
+
if (eDirectResource() != null && newContainer != null
&& eContainmentFeature(this, newContainer,
newContainerFeatureID) == null) {
- InternalEObject oldContainer = eInternalContainer();
int oldContainerFeatureID = eContainerFeatureID();
eBasicSetContainer(newContainer, newContainerFeatureID);
@@ -939,15 +940,19 @@
msgs);
}
- if (newContainer != null && (CHANGE_DESCRIPTION_CLASS == null
- || !(CHANGE_DESCRIPTION_CLASS.isInstance(newContainer)))) {
+ if (CHANGE_DESCRIPTION_CLASS == null
+ || !(CHANGE_DESCRIPTION_CLASS.isInstance(newContainer))) {
Resource.Internal eInternalResource = eInternalResource();
-
if (eInternalResource == null || !eInternalResource.isLoading()) {
- ElementOperations.unapplyAllNonApplicableStereotypes(this,
- false);
- ElementOperations.applyAllRequiredStereotypes(this, false);
+
+ if (oldContainer != null) {
+ ElementOperations.unapplyAllNonApplicableStereotypes(this, false);
+ }
+
+ if (newContainer != null) {
+ ElementOperations.applyAllRequiredStereotypes(this, false);
+ }
}
}