ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1611907 - in /webservices/axiom/trunk: aspects/core-aspects/src/main/java/org/apache/axiom/core/ implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
Date Sat, 19 Jul 2014 13:01:27 GMT
Author: veithen
Date: Sat Jul 19 13:01:26 2014
New Revision: 1611907

URL: http://svn.apache.org/r1611907
Log:
Optimize same owner document checking.

Modified:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentFragmentSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentSupport.aj
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNode.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNodeSupport.aj
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj?rev=1611907&r1=1611906&r2=1611907&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttributeSupport.aj
Sat Jul 19 13:01:26 2014
@@ -40,19 +40,11 @@ public aspect CoreAttributeSupport {
         owner = newOwnerDocument;
     }
     
-    public final CoreDocument CoreAttribute.coreGetOwnerDocument(boolean create) {
+    final CoreNode CoreAttribute.getRootOrOwnerDocument() {
         if (owner == null) {
-            if (create) {
-                CoreDocument document = createOwnerDocument();
-                owner = document;
-                return document;
-            } else {
-                return null;
-            }
-        } else if (owner instanceof CoreDocument) {
-            return (CoreDocument)owner;
+            return this;
         } else {
-            return ((CoreElement)owner).coreGetOwnerDocument(create);
+            return owner.getRootOrOwnerDocument();
         }
     }
 

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj?rev=1611907&r1=1611906&r2=1611907&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreChildNodeSupport.aj
Sat Jul 19 13:01:26 2014
@@ -58,22 +58,11 @@ public aspect CoreChildNodeSupport {
         setFlag(Flags.HAS_PARENT, false);
     }
     
-    public final CoreDocument CoreChildNode.coreGetOwnerDocument(boolean create) {
-        CoreNode root = this;
-        while (root.getFlag(Flags.HAS_PARENT)) {
-            root = ((CoreChildNode)root).owner;
-        }
-        if (root instanceof CoreChildNode) {
-            CoreChildNode rootChildNode = (CoreChildNode)root;
-            CoreDocument document = (CoreDocument)rootChildNode.owner;
-            if (document == null && create) {
-                document = createOwnerDocument();
-                rootChildNode.owner = document;
-            }
-            return document;
+    final CoreNode CoreChildNode.getRootOrOwnerDocument() {
+        if (owner == null) {
+            return this;
         } else {
-            // We get here if the root node is a document or document fragment
-            return root.coreGetOwnerDocument(create);
+            return owner.getRootOrOwnerDocument();
         }
     }
     

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentFragmentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentFragmentSupport.aj?rev=1611907&r1=1611906&r2=1611907&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentFragmentSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentFragmentSupport.aj
Sat Jul 19 13:01:26 2014
@@ -21,13 +21,14 @@ package org.apache.axiom.core;
 public aspect CoreDocumentFragmentSupport {
     private CoreDocument CoreDocumentFragment.ownerDocument;
     
-    public final CoreDocument CoreDocumentFragment.coreGetOwnerDocument(boolean create) {
-        if (create && ownerDocument == null) {
-            ownerDocument = createOwnerDocument();
+    final CoreNode CoreDocumentFragment.getRootOrOwnerDocument() {
+        if (ownerDocument == null) {
+            return this;
+        } else {
+            return ownerDocument;
         }
-        return ownerDocument;
     }
-
+    
     public final void CoreDocumentFragment.coreSetOwnerDocument(CoreDocument document) {
         ownerDocument = document;
     }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentSupport.aj?rev=1611907&r1=1611906&r2=1611907&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreDocumentSupport.aj
Sat Jul 19 13:01:26 2014
@@ -19,10 +19,10 @@
 package org.apache.axiom.core;
 
 public aspect CoreDocumentSupport {
-    public final CoreDocument CoreDocument.coreGetOwnerDocument(boolean create) {
+    final CoreNode CoreDocument.getRootOrOwnerDocument() {
         return this;
     }
-
+    
     public final void CoreDocument.coreSetOwnerDocument(CoreDocument document) {
         if (document != this) {
             throw new IllegalArgumentException();

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNode.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNode.java?rev=1611907&r1=1611906&r2=1611907&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNode.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNode.java
Sat Jul 19 13:01:26 2014
@@ -19,17 +19,6 @@
 package org.apache.axiom.core;
 
 public interface CoreNode {
-    /**
-     * Get the owner document to which this node belongs.
-     * 
-     * @param create
-     *            indicates whether the owner document should be created if it has not been
created
-     *            yet
-     * @return the owner document or <code>null</code> if the owner document
has not been created
-     *         yet and <code>create</code> is <code>false</code>
-     */
-    CoreDocument coreGetOwnerDocument(boolean create);
-
     void coreSetOwnerDocument(CoreDocument document);
     
     CoreDocument createOwnerDocument();

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNodeSupport.aj?rev=1611907&r1=1611906&r2=1611907&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNodeSupport.aj
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNodeSupport.aj
Sat Jul 19 13:01:26 2014
@@ -21,6 +21,34 @@ package org.apache.axiom.core;
 public aspect CoreNodeSupport {
     int CoreNode.flags;
 
+    abstract CoreNode CoreNode.getRootOrOwnerDocument();
+
+    /**
+     * Get the owner document to which this node belongs.
+     * 
+     * @param create
+     *            indicates whether the owner document should be created if it has not been
created
+     *            yet
+     * @return the owner document or <code>null</code> if the owner document
has not been created
+     *         yet and <code>create</code> is <code>false</code>
+     */
+    public final CoreDocument CoreNode.coreGetOwnerDocument(boolean create) {
+        CoreNode root = getRootOrOwnerDocument();
+        if (root instanceof CoreDocument) {
+            return (CoreDocument)root;
+        } else if (create) {
+            CoreDocument ownerDocument = createOwnerDocument();
+            root.coreSetOwnerDocument(ownerDocument);
+            return ownerDocument;
+        } else {
+            return null;
+        }
+    }
+    
+    public final boolean CoreNode.coreHasSameOwnerDocument(CoreNode other) {
+        return other.getRootOrOwnerDocument() == getRootOrOwnerDocument();
+    }
+
     final boolean CoreNode.getFlag(int flag) {
         return (flags & flag) != 0;
     }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?rev=1611907&r1=1611906&r2=1611907&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
(original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
Sat Jul 19 13:01:26 2014
@@ -396,9 +396,7 @@ public abstract class NodeImpl extends I
     }
     
     void checkSameOwnerDocument(Node otherNode) {
-        if (ownerDocument() != (otherNode instanceof AttrImpl
-                ? ((AttrImpl)otherNode).getOwnerDocument()
-                : ((NodeImpl)otherNode).ownerDocument())) {
+        if (!(otherNode instanceof NodeImpl && coreHasSameOwnerDocument((NodeImpl)otherNode)))
{
             throw newDOMException(DOMException.WRONG_DOCUMENT_ERR);
         }
     }



Mime
View raw message