xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkess...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm SAX2DTM.java
Date Wed, 05 Sep 2001 15:46:26 GMT
jkesselm    01/09/05 08:46:26

  Modified:    java/src/org/apache/xml/dtm/ref DTMDefaultBase.java
               java/src/org/apache/xml/dtm/ref/dom2dtm DOM2DTM.java
               java/src/org/apache/xml/dtm/ref/sax2dtm SAX2DTM.java
  Log:
  Removed the code which precalculated node levels
  (depth in tree). This has been IFed out for some time, but
  was retained in case we wanted to go back to it. Since it
  seems we're happy with this choice, zapping it entirely
  saves a few more cycles.
  
  It's simple enough to recreate if we change our minds later.
  
  Revision  Changes    Path
  1.19      +4 -26     xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java
  
  Index: DTMDefaultBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DTMDefaultBase.java	2001/08/28 19:23:23	1.18
  +++ DTMDefaultBase.java	2001/09/05 15:46:26	1.19
  @@ -90,12 +90,6 @@
    */
   public abstract class DTMDefaultBase implements DTM
   {
  -  /** %OPT% %REVIEW% When true, don't build the m_level array;
  -   *  instead, support _level()/getLevel() by counting upward to the
  -   *  root. This is exposed because SAX2DTM and DOM2DTM should
  -   *  respond to it. */
  -  protected static final boolean DISABLE_PRECALC_LEVEL=true;
  -
     /**
      * The number of nodes, which is also used to determine the next
      *  node index.
  @@ -105,12 +99,6 @@
     /** The expanded names, one array element for each node. */
     protected SuballocatedIntVector m_exptype;
   
  -  /** levels deep, one array element for each node.
  -   *
  -   * %REVIEW% Used only when DISABLE_PRECALC_LEVEL is false!
  -   */
  -  protected SuballocatedByteVector m_level;
  -
     /** First child values, one array element for each node. */
     protected SuballocatedIntVector m_firstch;
   
  @@ -223,9 +211,6 @@
       m_prevsib = new SuballocatedIntVector(m_initialblocksize);
       m_parent = new SuballocatedIntVector(m_initialblocksize);
   
  -    if(!DISABLE_PRECALC_LEVEL)
  -      m_level = new SuballocatedByteVector(m_initialblocksize);
  -
       m_mgr = mgr;
       m_documentBaseURI = (null != source) ? source.getSystemId() : null;
       m_dtmIdent = dtmIdentity;
  @@ -512,17 +497,10 @@
           return NULL;
       }
   
  -    if(DISABLE_PRECALC_LEVEL)
  -    {
  -      int i=0;
  -      while(NULL != (identity=_parent(identity)))
  -        ++i;
  -      return i;
  -    }
  -    else
  -    {
  -      return m_level.elementAt(identity);
  -    }
  +    int i=0;
  +    while(NULL != (identity=_parent(identity)))
  +      ++i;
  +    return i;
     }
   
     /**
  
  
  
  1.16      +5 -16     xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java
  
  Index: DOM2DTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/DOM2DTM.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DOM2DTM.java	2001/07/20 18:48:11	1.15
  +++ DOM2DTM.java	2001/09/05 15:46:26	1.16
  @@ -148,7 +148,7 @@
       m_pos=m_root = domSource.getNode();
       // Initialize DTM navigation
       m_last_parent=m_last_kid=NULL;
  -    m_last_kid=addNode(m_root, 0, m_last_parent,m_last_kid, NULL);
  +    m_last_kid=addNode(m_root, m_last_parent,m_last_kid, NULL);
   
       // Apparently the domSource root may not actually be the
       // Document node. If it's an Element node, we need to immediately
  @@ -169,7 +169,7 @@
             // No need to force nodetype in this case;
             // addNode() will take care of switching it from
             // Attr to Namespace if necessary.
  -          attrIndex=addNode(attrs.item(i),1,0,attrIndex,NULL);
  +          attrIndex=addNode(attrs.item(i),0,attrIndex,NULL);
             m_firstch.setElementAt(DTM.NULL,attrIndex);
           }
           // Terminate list of attrs, and make sure they aren't
  @@ -188,7 +188,6 @@
      * Construct the node map from the node.
      *
      * @param node The node that is to be added to the DTM.
  -   * @param level The current level in the tree.
      * @param parentIndex The current parent index.
      * @param previousSibling The previous sibling index.
      * @param forceNodeType If not DTM.NULL, overrides the DOM node type.
  @@ -197,7 +196,7 @@
      *
      * @return The index identity of the node that was added.
      */
  -  protected int addNode(Node node, int level, int parentIndex,
  +  protected int addNode(Node node, int parentIndex,
                           int previousSibling, int forceNodeType)
     {
       int nodeIndex = m_nodes.size();
  @@ -239,12 +238,6 @@
       
       m_nodes.addElement(node);
       
  -    // Do casts here so that if we change the sizes, the changes are localized.
  -    // %REVIEW% Remember to change this cast if we change
  -    // m_level's type, or we may truncate values without warning!
  -    if(!DTMDefaultBase.DISABLE_PRECALC_LEVEL)
  -      m_level.addElement((byte)level); // setElementAt(level,nodeIndex)?
  -    
       m_firstch.setElementAt(NOTPROCESSED,nodeIndex);
       m_nextsib.setElementAt(NOTPROCESSED,nodeIndex);
       m_prevsib.setElementAt(previousSibling,nodeIndex);
  @@ -520,10 +513,7 @@
           // Inserting next. NOTE that we force the node type; for
           // coalesced Text, this records CDATASections adjacent to
           // ordinary Text as Text.
  -	int level=0;
  -	if(!DTMDefaultBase.DISABLE_PRECALC_LEVEL)
  -	  level=m_level.elementAt(m_last_parent)+1;
  -	int nextindex=addNode(next,level,m_last_parent,m_last_kid,
  +	int nextindex=addNode(next,m_last_parent,m_last_kid,
   			      nexttype);
   	
           m_last_kid=nextindex;
  @@ -536,14 +526,13 @@
               int attrsize=(attrs==null) ? 0 : attrs.getLength();
               if(attrsize>0)
                 {
  -                int attrlevel=level+1;
                   int attrIndex=NULL; // start with no previous sib
                   for(int i=0;i<attrsize;++i)
                     {
                       // No need to force nodetype in this case;
                       // addNode() will take care of switching it from
                       // Attr to Namespace if necessary.
  -                    attrIndex=addNode(attrs.item(i),attrlevel,
  +                    attrIndex=addNode(attrs.item(i),
                                         nextindex,attrIndex,NULL);
                       m_firstch.setElementAt(DTM.NULL,attrIndex);
                     }
  
  
  
  1.17      +8 -26     xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
  
  Index: SAX2DTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- SAX2DTM.java	2001/08/13 05:28:50	1.16
  +++ SAX2DTM.java	2001/09/05 15:46:26	1.17
  @@ -117,9 +117,6 @@
     /** The parent stack, needed only for construction. */
     transient private IntStack m_parents = new IntStack();
   
  -  /** The current construction level, needed only for construction time. */
  -  transient private int m_levelAmount = 0;
  -
     /** The current previous node, needed only for construction time. */
     transient private int m_previous = 0;
   
  @@ -800,7 +797,6 @@
      *
      * @param type raw type ID, one of DTM.XXX_NODE.
      * @param expandedTypeID The expended type ID.
  -   * @param level The current level in the tree.
      * @param parentIndex The current parent index.
      * @param previousSibling The previous sibling index.
      * @param dataOrPrefix index into m_data table, or string handle.
  @@ -809,19 +805,13 @@
      *
      * @return The index identity of the node that was added.
      */
  -  protected int addNode(int type, int expandedTypeID, int level,
  +  protected int addNode(int type, int expandedTypeID,
                           int parentIndex, int previousSibling,
                           int dataOrPrefix, boolean canHaveFirstChild)
     {
   
       // Common to all nodes:
       int nodeIndex = m_size++;
  -    // %REVIEW% This is being phased out
  -    if(!DTMDefaultBase.DISABLE_PRECALC_LEVEL)
  -    {
  -      // Do the hard casts here, to localize changes that may have to be made.
  -      m_level.addElement((byte)level); 
  -    }
       m_firstch.addElement(canHaveFirstChild ? NOTPROCESSED : DTM.NULL);
       m_nextsib.addElement(NOTPROCESSED);
       m_prevsib.addElement(previousSibling);
  @@ -1318,7 +1308,7 @@
           int exName = m_expandedNameTable.getExpandedTypeID(DTM.TEXT_NODE);
           int dataIndex = m_data.size();
   
  -        m_previous = addNode(m_coalescedTextType, exName, m_levelAmount,
  +        m_previous = addNode(m_coalescedTextType, exName,
                                m_parents.peek(), m_previous, dataIndex, false);
   
           m_data.addElement(m_textPendingStart);
  @@ -1477,9 +1467,7 @@
     {
       int doc = addNode(DTM.DOCUMENT_NODE,
                         m_expandedNameTable.getExpandedTypeID(DTM.DOCUMENT_NODE),
  -                      m_levelAmount, DTM.NULL, DTM.NULL, 0, true);
  -
  -    m_levelAmount++;
  +                      DTM.NULL, DTM.NULL, 0, true);
   
       m_parents.push(doc);
   
  @@ -1516,8 +1504,6 @@
       m_prefixMappings = null;
       m_contextIndexes = null;
   
  -    m_levelAmount--;
  -
       m_endDocumentOccured = true;
     }
   
  @@ -1648,13 +1634,11 @@
       String prefix = getPrefix(qName, uri);
       int prefixIndex = (null != prefix)
                         ? m_valuesOrPrefixes.stringToIndex(qName) : 0;
  -    int elemNode = addNode(DTM.ELEMENT_NODE, exName, m_levelAmount,
  +    int elemNode = addNode(DTM.ELEMENT_NODE, exName,
                              m_parents.peek(), m_previous, prefixIndex, true);
   
       indexNode(exName, elemNode);
       
  -    m_levelAmount++;
  -
       m_parents.push(elemNode);
   
       int startDecls = m_contextIndexes.peek();
  @@ -1674,7 +1658,7 @@
   
         int val = m_valuesOrPrefixes.stringToIndex(declURL);
   
  -      prev = addNode(DTM.NAMESPACE_NODE, exName, m_levelAmount, elemNode,
  +      prev = addNode(DTM.NAMESPACE_NODE, exName, elemNode,
                        prev, val, false);
       }
   
  @@ -1729,7 +1713,7 @@
         }
   
         exName = m_expandedNameTable.getExpandedTypeID(attrUri, attrLocalName, nodeType);
  -      prev = addNode(nodeType, exName, m_levelAmount, elemNode, prev, val,
  +      prev = addNode(nodeType, exName, elemNode, prev, val,
                        false);
       }
   
  @@ -1788,8 +1772,6 @@
       m_prefixMappings.setSize(m_contextIndexes.pop());
       m_contextIndexes.push(m_prefixMappings.size());  // for the next element.
   
  -    m_levelAmount--;
  -
       int lastNode = m_previous;
   
       m_previous = m_parents.pop();
  @@ -1888,7 +1870,7 @@
       int dataIndex = m_valuesOrPrefixes.stringToIndex(data);
   
       m_previous = addNode(DTM.PROCESSING_INSTRUCTION_NODE, exName,
  -                         m_levelAmount, m_parents.peek(), m_previous,
  +                         m_parents.peek(), m_previous,
                            dataIndex, false);
     }
   
  @@ -2208,7 +2190,7 @@
       int dataIndex = m_valuesOrPrefixes.stringToIndex(new String(ch, start,
                         length));
   
  -    m_previous = addNode(DTM.COMMENT_NODE, exName, m_levelAmount,
  +    m_previous = addNode(DTM.COMMENT_NODE, exName, 
                            m_parents.peek(), m_previous, dataIndex, false);
     }
   
  
  
  

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


Mime
View raw message