Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkhussey2006-06-14 22:04:27 +0000
committerkhussey2006-06-14 22:04:27 +0000
commita315bf7b791373d19ae175ee08f0cd7805eca15e (patch)
treeef0057ae2365fb36afec8edc60bcccf46dbbc1cb
parentae43f229fcbbde7570d4335062363029ba218a3a (diff)
downloadorg.eclipse.uml2.test-a315bf7b791373d19ae175ee08f0cd7805eca15e.tar.gz
org.eclipse.uml2.test-a315bf7b791373d19ae175ee08f0cd7805eca15e.tar.xz
org.eclipse.uml2.test-a315bf7b791373d19ae175ee08f0cd7805eca15e.zip
[147126] Improving performance of allOwnedElements(), allNamespaces().
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ElementOperations.java28
-rw-r--r--plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/NamedElementOperations.java25
2 files changed, 33 insertions, 20 deletions
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ElementOperations.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ElementOperations.java
index 2adfa6d5..fc9ee48f 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ElementOperations.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ElementOperations.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - initial API and implementation
*
- * $Id: ElementOperations.java,v 1.40 2006/05/11 04:16:53 khussey Exp $
+ * $Id: ElementOperations.java,v 1.41 2006/06/14 22:04:27 khussey Exp $
*/
package org.eclipse.uml2.uml.internal.operations;
@@ -1417,6 +1417,22 @@ public class ElementOperations
destroy((EObject) element);
}
+ protected static EList allOwnedElements(Element element,
+ EList allOwnedElements) {
+
+ for (Iterator ownedElements = element.getOwnedElements().iterator(); ownedElements
+ .hasNext();) {
+
+ Element ownedElement = (Element) ownedElements.next();
+
+ if (allOwnedElements.add(ownedElement)) {
+ allOwnedElements(ownedElement, allOwnedElements);
+ }
+ }
+
+ return allOwnedElements;
+ }
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -1427,14 +1443,8 @@ public class ElementOperations
* @generated NOT
*/
public static EList allOwnedElements(Element element) {
- EList ownedElements = element.getOwnedElements();
- EList allOwnedElements = new UniqueEList.FastCompare(ownedElements);
-
- for (Iterator oe = ownedElements.iterator(); oe.hasNext();) {
- allOwnedElements.addAll(((Element) oe.next()).allOwnedElements());
- }
-
- return ECollections.unmodifiableEList(allOwnedElements);
+ return ECollections.unmodifiableEList(allOwnedElements(element,
+ new UniqueEList.FastCompare()));
}
/**
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/NamedElementOperations.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/NamedElementOperations.java
index d5045d68..b28d1168 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/NamedElementOperations.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/NamedElementOperations.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - initial API and implementation
*
- * $Id: NamedElementOperations.java,v 1.17 2006/05/23 17:32:16 khussey Exp $
+ * $Id: NamedElementOperations.java,v 1.18 2006/06/14 22:04:27 khussey Exp $
*/
package org.eclipse.uml2.uml.internal.operations;
@@ -238,6 +238,17 @@ public class NamedElementOperations
return getQualifiedName(namedElement, namedElement.separator());
}
+ protected static EList allNamespaces(NamedElement namedElement,
+ EList allNamespaces) {
+ Namespace namespace = namedElement.getNamespace();
+
+ if (namespace != null && allNamespaces.add(namespace)) {
+ allNamespaces(namespace, allNamespaces);
+ }
+
+ return allNamespaces;
+ }
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -251,16 +262,8 @@ public class NamedElementOperations
* @generated NOT
*/
public static EList allNamespaces(NamedElement namedElement) {
- EList allNamespaces = new UniqueEList.FastCompare();
-
- Namespace namespace = namedElement.getNamespace();
-
- if (namespace != null) {
- allNamespaces.add(namespace);
- allNamespaces.addAll(namespace.allNamespaces());
- }
-
- return ECollections.unmodifiableEList(allNamespaces);
+ return ECollections.unmodifiableEList(allNamespaces(namedElement,
+ new UniqueEList.FastCompare()));
}
/**

Back to the top