jkesselm 01/06/21 14:13:41
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:
Replace the explicitly (and inefficiently) reallocated
byte[] m_level with a SuballocatedByteVector. Faster build
(especially on large documents), slightly slower retrieval.
Note that we may phase this field out and go back to computed
level, since recent changes to other parts of Xalan make fast
retrieval of level less critical.
Revision Changes Path
1.8 +17 -25
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DTMDefaultBase.java 2001/06/21 18:58:48 1.7
+++ DTMDefaultBase.java 2001/06/21 21:13:35 1.8
@@ -58,6 +58,7 @@
import org.apache.xml.dtm.*;
import org.apache.xml.utils.SuballocatedIntVector;
+import org.apache.xml.utils.SuballocatedByteVector;
import org.apache.xml.utils.IntStack;
import org.apache.xml.utils.BoolStack;
import org.apache.xml.utils.StringBufferPool;
@@ -95,8 +96,18 @@
/** The expanded names, one array element for each node. */
protected SuballocatedIntVector m_exptype;
- /** levels deep, one array element for each node. */
- protected byte[] m_level;
+ /** levels deep, one array element for each node.
+ *
+ * %REVIEW% Are 256 levels really enough? (Yes for most docs, but maybe not
+ * for something deeply structured.) Should this be shorts instead? Or
give up
+ * and go back to int?
+ *
+ * %REVIEW% We may be concluding that, given some of the other changes DTM
+ * and the new traversal code have bought us, level no longer needs to be
+ * tracked at all. Keep it for now because it's useful as a DTM diagnostic,
+ * but consider phasing it out.
+ */
+ protected SuballocatedByteVector m_level;
/** First child values, one array element for each node. */
protected SuballocatedIntVector m_firstch;
@@ -206,7 +217,7 @@
}
m_exptype = new SuballocatedIntVector(m_initialblocksize);
- m_level = new byte[m_initialblocksize];
+ m_level = new SuballocatedByteVector(m_initialblocksize);
m_firstch = new SuballocatedIntVector(m_initialblocksize);
m_nextsib = new SuballocatedIntVector(m_initialblocksize);
m_prevsib = new SuballocatedIntVector(m_initialblocksize);
@@ -439,26 +450,7 @@
*/
protected void ensureSize(int index)
{
-
- int capacity = m_level.length;
-
- if (capacity <= index)
- {
- int newcapacity = capacity + m_blocksize;
- // ps.println("resizing to new capacity: "+newcapacity);
-
- // We've cut over to SuballocatedIntVector, which is self-
- // sizing.
- // %OPT% May want to define a ByteVector as well, though for now we
can
- // handle m_level the old way...
- byte[] level = m_level;
- m_level = new byte[newcapacity];
- System.arraycopy(level, 0, m_level, 0, capacity);
- // %REVIEW%
- m_blocksize = m_blocksize + m_blocksize;
- if(m_blocksize >= (1024*8))
- m_blocksize = 1024*8;
- }
+ // We've cut over to Suballocated*Vector, which are self-sizing.
}
/**
@@ -517,7 +509,7 @@
{
if (identity < m_size)
- return m_level[identity];
+ return m_level.elementAt(identity);
// Check to see if the information requested has been processed, and,
// if not, advance the iterator until we the information has been
@@ -529,7 +521,7 @@
if (!isMore)
return NULL;
else if (identity < m_size)
- return m_level[identity];
+ return m_level.elementAt(identity);
}
}
1.7 +3 -2
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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DOM2DTM.java 2001/06/21 18:59:13 1.6
+++ DOM2DTM.java 2001/06/21 21:13:38 1.7
@@ -183,7 +183,8 @@
// 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!
- m_level[nodeIndex] = (byte)level;
+ //m_level[nodeIndex] = (byte)level;
+ m_level.addElement((byte)level); // setElementAt(level,nodeIndex)?
// %REVIEW% The Namespace Spec currently says that Namespaces are
// processed in a non-namespace-aware manner, by matching the
@@ -483,7 +484,7 @@
// Inserting next. NOTE that we force the node type; for
// coalesced Text, this records CDATASections adjacent to
// ordinary Text as Text.
- int level=m_level[m_last_parent]+1;
+ int level=m_level.elementAt(m_last_parent)+1;
int nextindex=addNode(next,level,m_last_parent,m_last_kid,
nexttype);
m_last_kid=nextindex;
1.5 +1 -1
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SAX2DTM.java 2001/06/21 18:59:02 1.4
+++ SAX2DTM.java 2001/06/21 21:13:40 1.5
@@ -837,7 +837,7 @@
ensureSize(nodeIndex);
// Do the hard casts here, so we localize changes that may have to be
made.
- m_level[nodeIndex] = (byte) level;
+ m_level.addElement((byte)level); // %REVIEW%
setElementAt(level,nodeIndex)?
m_firstch.setElementAt(canHaveFirstChild ? NOTPROCESSED :
DTM.NULL,nodeIndex);
m_nextsib.setElementAt(NOTPROCESSED,nodeIndex);
m_prevsib.setElementAt(previousSibling,nodeIndex);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]