You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ga...@apache.org on 2003/05/12 12:23:38 UTC

cvs commit: xml-xerces/c/src/xercesc/dom/impl DOMParentNode.cpp

gareth      2003/05/12 03:23:38

  Modified:    c/src/xercesc/dom/impl DOMParentNode.cpp
  Log:
  Optimization. No need to check for cycles in the tree if the node has no children. Patch by Alby Massari.
  
  Revision  Changes    Path
  1.13      +11 -8     xml-xerces/c/src/xercesc/dom/impl/DOMParentNode.cpp
  
  Index: DOMParentNode.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMParentNode.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DOMParentNode.cpp	29 Jan 2003 16:22:42 -0000	1.12
  +++ DOMParentNode.cpp	12 May 2003 10:23:38 -0000	1.13
  @@ -190,13 +190,16 @@
   
   
       // Prevent cycles in the tree
  -    bool treeSafe=true;
  -    for(DOMNode *a=castToNode(this)->getParentNode();
  -        treeSafe && a!=0;
  -        a=a->getParentNode())
  -        treeSafe=(newChild!=a);
  -    if(!treeSafe)
  -        throw DOMException(DOMException::HIERARCHY_REQUEST_ERR,0);
  +    //only need to do this if the node has children
  +    if(newChild->hasChildNodes()) {
  +        bool treeSafe=true;
  +        for(DOMNode *a=castToNode(this)->getParentNode();
  +            treeSafe && a!=0;
  +            a=a->getParentNode())
  +            treeSafe=(newChild!=a);
  +        if(!treeSafe)
  +            throw DOMException(DOMException::HIERARCHY_REQUEST_ERR,0);
  +    }
   
       // refChild must in fact be a child of this node (or 0)
       if (refChild!=0 && refChild->getParentNode() != castToNode(this))
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org