mkwan 2003/02/27 13:44:36
Modified: java/src/org/apache/xml/dtm/ref/sax2dtm Tag: XSLTC_DTM
SAX2DTM2.java
Log:
XSLTC_DTM performance work
Small improvement to DescendantIterator and TypedDescendantIterator.
Revision Changes Path
No revision
No revision
1.1.2.21 +21 -16
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.20
retrieving revision 1.1.2.21
diff -u -r1.1.2.20 -r1.1.2.21
--- SAX2DTM2.java 27 Feb 2003 19:56:04 -0000 1.1.2.20
+++ SAX2DTM2.java 27 Feb 2003 21:44:35 -0000 1.1.2.21
@@ -1510,17 +1510,21 @@
int node = _currentNode;
int type;
+ // %OPT% If the startNode is the root node, do not need
+ // to do the isDescendant() check.
if (startNode == ROOTNODE) {
+ int eType;
do {
node++;
- type = _type2(node);
+ eType = _exptype2(node);
- if (NULL == type) {
+ if (NULL == eType) {
_currentNode = NULL;
return END;
}
- } while(ATTRIBUTE_NODE == type || TEXT_NODE == type
- || NAMESPACE_NODE == type);
+ } while (eType == TEXT_NODE
+ || (type = m_extendedTypes[eType].getNodeType()) ==
ATTRIBUTE_NODE
+ || type == NAMESPACE_NODE);
}
else {
do {
@@ -1586,24 +1590,24 @@
*/
public int next()
{
- int node;
- int expType;
-
+ final int startNode = _startNode;
if (_startNode == NULL) {
return NULL;
}
- node = _currentNode;
+ int node = _currentNode;
+ int expType;
final int nodeType = _nodeType;
- if (nodeType >= DTM.NTYPES)
+
+ if (nodeType != DTM.ELEMENT_NODE)
{
do
{
node++;
expType = _exptype2(node);
- if (NULL == expType ||!isDescendant(node)) {
+ if (NULL == expType || _parent2(node) < startNode && startNode !=
node) {
_currentNode = NULL;
return END;
}
@@ -1613,7 +1617,7 @@
// %OPT% If the start node is root (e.g. in the case of //node),
// we can save the isDescendant() check, because all nodes are
// descendants of root.
- else if (_startNode == DTMDefaultBase.ROOTNODE)
+ else if (startNode == DTMDefaultBase.ROOTNODE)
{
do
{
@@ -1624,8 +1628,8 @@
_currentNode = NULL;
return END;
}
- }
- while (m_extendedTypes[expType].getNodeType() != nodeType && expType !=
nodeType);
+ } while (expType < DTM.NTYPES
+ || m_extendedTypes[expType].getNodeType() != DTM.ELEMENT_NODE);
}
else
{
@@ -1634,14 +1638,15 @@
node++;
expType = _exptype2(node);
- if (NULL == expType ||!isDescendant(node)) {
+ if (NULL == expType || _parent2(node) < startNode && startNode !=
node) {
_currentNode = NULL;
return END;
}
}
- while (m_extendedTypes[expType].getNodeType() != nodeType && expType
!= nodeType);
+ while (expType < DTM.NTYPES
+ || m_extendedTypes[expType].getNodeType() != DTM.ELEMENT_NODE);
}
-
+
_currentNode = node;
return returnNode(makeNodeHandle(node));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]