mkwan       2003/02/13 09:05:02

  Modified:    java/src/org/apache/xml/dtm/ref/sax2dtm Tag: XSLTC_DTM
                        SAX2DTM2.java
  Log:
  XSLTC_DTM performance work
  Small improvement in TypedSingltonIterator, TypedRootIterator and 
ParentIterator.
  Change the code to use the optimized set of base accessor methods.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.9   +49 -31    
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM2.java
  
  Index: SAX2DTM2.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM2.java,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- SAX2DTM2.java     11 Feb 2003 21:39:35 -0000      1.1.2.8
  +++ SAX2DTM2.java     13 Feb 2003 17:05:01 -0000      1.1.2.9
  @@ -146,7 +146,7 @@
     {
   
       /** The extended type ID that was requested. */
  -    private int _nodeType = -1;
  +    private int _nodeType = DTM.NULL;
   
       /**
        * Set start to END should 'close' the iterator,
  @@ -164,8 +164,12 @@
         if (_isRestartable)
         {
           _startNode = node;
  -        _currentNode = getParent(node);
  -
  +        
  +        if (node != DTM.NULL)
  +          _currentNode = _parent2(makeNodeIdentity(node));
  +        else
  +          _currentNode = DTM.NULL;
  +        
           return resetPosition();
         }
   
  @@ -199,20 +203,28 @@
       public int next()
       {
         int result = _currentNode;
  +      if (result == END)
  +        return DTM.NULL;
   
  -      if (_nodeType >= DTM.NTYPES) {
  -        if (_nodeType != getExpandedTypeID(_currentNode)) {
  -          result = END;
  +      // %OPT% The most common case is handled first.
  +      if (_nodeType == NULL) {
  +        _currentNode = END;
  +        return returnNode(makeNodeHandle(result));
  +      }
  +      else if (_nodeType >= DTM.NTYPES) {
  +        if (_nodeType == _exptype2(result)) {
  +          _currentNode = END;
  +       return returnNode(makeNodeHandle(result));
           }
  -      } else if (_nodeType != NULL) {
  -        if (_nodeType != getNodeType(_currentNode)) {
  -          result = END;
  +      } 
  +      else {
  +        if (_nodeType == _type2(result)) {
  +       _currentNode = END;
  +       return returnNode(makeNodeHandle(result));          
           }
         }
  -
  -      _currentNode = END;
  -
  -      return returnNode(result);
  +      
  +      return DTM.NULL;      
       }
     }  // end of ParentIterator
   
  @@ -349,32 +361,33 @@
        */
       public int next()
       {
  -     if(_startNode == _currentNode)
  +      if(_startNode == _currentNode)
           return NULL;
   
  -      int nodeType = _nodeType;
  -      int node = _startNode;
  -      int expType = getExpandedTypeID(node);
  +      final int node = _startNode;
  +      int expType = _exptype2(makeNodeIdentity(node));
   
         _currentNode = node;
   
  -      if (nodeType >= DTM.NTYPES) {
  -        if (nodeType == expType) {
  +      if (_nodeType >= DTM.NTYPES) {
  +        if (_nodeType == expType) {
             return returnNode(node);
           }
  -      } else {
  +      } 
  +      else {
           if (expType < DTM.NTYPES) {
  -          if (expType == nodeType) {
  +          if (expType == _nodeType) {
               return returnNode(node);
             }
  -        } else {
  -          if (m_extendedTypes[expType].getNodeType() == nodeType) {
  +        } 
  +        else {
  +          if (m_extendedTypes[expType].getNodeType() == _nodeType) {
               return returnNode(node);
             }
           }
         }
   
  -      return END;
  +      return NULL;
       }
     }  // end of TypedRootIterator
   
  @@ -1554,18 +1567,19 @@
       public int next()
       {
   
  -      //final int result = super.next();
         final int result = _currentNode;
  -      int nodeType = _nodeType;
  -
  +      if (result == END)
  +        return DTM.NULL;
  +      
         _currentNode = END;
   
  -      if (nodeType >= DTM.NTYPES) {
  -        if (getExpandedTypeID(result) == nodeType) {
  +      if (_nodeType >= DTM.NTYPES) {
  +        if (_exptype2(makeNodeIdentity(result)) == _nodeType) {
             return returnNode(result);
           }
  -      } else {
  -        if (getNodeType(result) == nodeType) {
  +      } 
  +      else {
  +        if (_type2(makeNodeIdentity(result)) == _nodeType) {
             return returnNode(result);
           }
         }
  @@ -2062,6 +2076,10 @@
   
     /**
      * Override SAX2DTM.getStringValue(int)
  +   *
  +   *%REVISIT% There should be no need to override this interface.
  +   * It is only a temporary solution to keep the extensions working.
  +   * We can get rid of this when the code becomes more integrated.
      *
      * If the caller supplies an XMLStringFactory, the getStringValue() 
interface
      * in SAX2DTM will be called. Otherwise just calls getStringValueX() and
  
  
  

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

Reply via email to