morten      01/09/20 07:21:07

  Modified:    java/src/org/apache/xalan/xsltc/dom DOMImpl.java
  Log:
  Fix for ChildrenIterator to speed up last() and position() calls.
  PR:           n/a
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.27      +22 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
  
  Index: DOMImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- DOMImpl.java      2001/09/19 13:22:51     1.26
  +++ DOMImpl.java      2001/09/20 14:21:07     1.27
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DOMImpl.java,v 1.26 2001/09/19 13:22:51 morten Exp $
  + * @(#)$Id: DOMImpl.java,v 1.27 2001/09/20 14:21:07 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -591,8 +591,10 @@
       private final class ChildrenIterator extends NodeIteratorBase {
        // child to return next
        private int _currentChild;
  -         
  +     private int _last = -1;
  +
        public NodeIterator setStartNode(final int node) {
  +         _last = -1;
            if (_isRestartable) {
                _currentChild = hasChildren(node)
                    ? _offsetOrChild[_startNode = node] : END;
  @@ -615,6 +617,16 @@
            _currentChild = _markedNode;
        }
   
  +     public int getLast() {
  +         if (_last == -1) {
  +             int node = _offsetOrChild[_startNode];
  +             do {
  +                 ++_last;
  +             } while ((node = _nextSibling[node]) != END);
  +         }
  +         return(_last);
  +     }
  +
       } // end of ChildrenIterator
   
   
  @@ -680,6 +692,14 @@
                    ? _offsetOrChild[_startNode = node] : END;
                return resetPosition();
            }
  +         return this;
  +     }
  +
  +     public NodeIterator reset() {
  +         if (hasChildren(_startNode))
  +             _currentChild = _offsetOrChild[_startNode];
  +         else
  +             _currentChild = END;
            return this;
        }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to