XSLTC_DTM performance work
Improvement in DTM building. Make the code more efficient
in a few expensive interfaces.


git-svn-id: https://svn.apache.org/repos/asf/xalan/java/branches/XSLTC_DTM@337351 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java b/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
index a4af213..f929db3 100644
--- a/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
+++ b/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
@@ -2097,15 +2097,16 @@
       m_textPendingStart = m_chars.size();
       m_coalescedTextType = m_textType;
     }
-
-    m_chars.append(ch, start, length);
-
     // Type logic: If all adjacent text is CDATASections, the
     // concatentated text is treated as a single CDATASection (see
     // initialization above).  If any were ordinary Text, the whole
     // thing is treated as Text. This may be worth %REVIEW%ing.
-    if (m_textType == DTM.TEXT_NODE)
+    else if (m_textType == DTM.TEXT_NODE)
+    {
       m_coalescedTextType = DTM.TEXT_NODE;
+    }
+
+    m_chars.append(ch, start, length);
   }
 
   /**
diff --git a/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM2.java b/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM2.java
index d7c57dc..3a9e348 100644
--- a/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM2.java
+++ b/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM2.java
@@ -1825,6 +1825,9 @@
   // The current index into the m_values Vector.
   private int m_valueIndex = 0;
   
+  // The maximum value of the current node index.
+  private int m_maxNodeIndex;
+  
   // Cache the shift and mask values for the SuballocatedIntVectors.
   protected int m_SHIFT;
   protected int m_MASK;
@@ -1897,6 +1900,8 @@
     // the increment to a bigger number.
     m_values = new Vector(32, 512);
     
+    m_maxNodeIndex = 1 << DTMManager.IDENT_DTM_NODE_BITS;
+    
     // Set the map0 values in the constructor.
     m_exptype_map0 = m_exptype.getMap0();
     m_nextsib_map0 = m_nextsib.getMap0();
@@ -2278,15 +2283,17 @@
       m_prefixMappings.setSize(topContextIndex);
     }
 
-    int lastNode = m_previous;
+    // int lastNode = m_previous;
 
     m_previous = m_parents.pop();
 
     // If lastNode is still DTM.NULL, this element had no children
+    /*
     if (DTM.NULL == lastNode)
       m_firstch.setElementAt(DTM.NULL,m_previous);
     else
       m_nextsib.setElementAt(DTM.NULL,lastNode);
+    */
 
     popShouldStripWhitespace();
   }
@@ -2395,9 +2402,11 @@
     int nodeIndex = m_size++;
 
     // Have we overflowed a DTM Identity's addressing range?
-    if(m_dtmIdent.size() == (nodeIndex>>>DTMManager.IDENT_DTM_NODE_BITS))
+    //if(m_dtmIdent.size() == (nodeIndex>>>DTMManager.IDENT_DTM_NODE_BITS))
+    if (nodeIndex == m_maxNodeIndex)
     {
       addNewDTMID(nodeIndex);
+      m_maxNodeIndex += (1 << DTMManager.IDENT_DTM_NODE_BITS);
     }
 
     m_firstch.addElement(DTM.NULL);
@@ -2410,10 +2419,6 @@
       m_prevsib.addElement(previousSibling);
     }
 
-    if (DTM.NULL != previousSibling) {
-      m_nextsib.setElementAt(nodeIndex,previousSibling);
-    }
-
     if (m_locator != null && m_useSourceLocationProperty) {
       setSourceLocation();
     }
@@ -2430,7 +2435,10 @@
     case DTM.ATTRIBUTE_NODE:
       break;
     default:
-      if (DTM.NULL == previousSibling && DTM.NULL != parentIndex) {
+      if (DTM.NULL != previousSibling) {
+        m_nextsib.setElementAt(nodeIndex,previousSibling);
+      }
+      else if (DTM.NULL != parentIndex) {
         m_firstch.setElementAt(nodeIndex,parentIndex);
       }
       break;