Author: atsushi
Date: 2005-03-14 23:34:36 -0500 (Mon, 14 Mar 2005)
New Revision: 41823
Modified:
trunk/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs
trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs
Log:
2004-03-15 Atsushi Enomoto <[EMAIL PROTECTED]>
* DTMXPathDocumentBuilder2.cs : Eliminating Depth. Store parent index
stack instead of depending on Depth.
Just use hasAttributes and hasLocalNs instead of indices.
* DTMXPathNavigator2.cs : (get_Value) Check empty element earlier.
Modified: trunk/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog 2005-03-15 04:26:50 UTC
(rev 41822)
+++ trunk/mcs/class/System.XML/Mono.Xml.XPath/ChangeLog 2005-03-15 04:34:36 UTC
(rev 41823)
@@ -1,3 +1,10 @@
+2004-03-15 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * DTMXPathDocumentBuilder2.cs : Eliminating Depth. Store parent index
+ stack instead of depending on Depth.
+ Just use hasAttributes and hasLocalNs instead of indices.
+ * DTMXPathNavigator2.cs : (get_Value) Check empty element earlier.
+
2004-03-14 Atsushi Enomoto <[EMAIL PROTECTED]>
* DTMXPathNavigator2.cs : Eliminating Depth. (To completely eliminate,
Modified: trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs
2005-03-15 04:26:50 UTC (rev 41822)
+++ trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs
2005-03-15 04:34:36 UTC (rev 41823)
@@ -130,18 +130,19 @@
int nodeIndex;
int attributeIndex;
int nsIndex;
- int parentForFirstChild;
// for attribute processing; should be reset per each element.
- int firstAttributeIndex;
- int lastNsIndexInCurrent;
+ bool hasAttributes;
+ bool hasLocalNs;
int attrIndexAtStart;
int nsIndexAtStart;
- int prevSibling;
int lastNsInScope;
bool skipRead = false;
+ int [] parentStack = new int [10];
+ int parentStackIndex = 0;
+
public DTMXPathDocument2 CreateDocument ()
{
return new DTMXPathDocument2 (nameTable,
@@ -177,7 +178,7 @@
this.nodeIndex = 1;
this.lastNsInScope = 1;
- this.parentForFirstChild = nodeIndex;
+ parentStack [0] = nodeIndex;
while (!xmlReader.EOF)
Read ();
@@ -211,15 +212,9 @@
if (!xmlReader.Read ())
return;
skipRead = false;
- int parent = nodeIndex;
+ int parent = parentStack [parentStackIndex];
+ int prevSibling = nodeIndex;
- if (nodes [nodeIndex].Depth >= xmlReader.Depth) {
- // if not, then current node is parent.
- while (xmlReader.Depth <= nodes [parent].Depth)
- parent = nodes [parent].Parent;
- }
-
- prevSibling = nodeIndex;
switch (xmlReader.NodeType) {
case XmlNodeType.Element:
case XmlNodeType.CDATA:
@@ -227,17 +222,17 @@
case XmlNodeType.Comment:
case XmlNodeType.Text:
case XmlNodeType.ProcessingInstruction:
- if (parentForFirstChild >= 0)
+ if (parent == nodeIndex)
prevSibling = 0;
else
- while (nodes [prevSibling].Depth !=
xmlReader.Depth)
+ while (nodes [prevSibling].Parent !=
parent)
prevSibling = nodes
[prevSibling].Parent;
nodeIndex++;
if (prevSibling != 0)
nodes [prevSibling].NextSibling =
nodeIndex;
- if (parentForFirstChild >= 0)
+ if (parentStack [parentStackIndex] == nodeIndex
- 1)
nodes [parent].FirstChild = nodeIndex;
break;
case XmlNodeType.Whitespace:
@@ -246,15 +241,13 @@
else
goto default;
case XmlNodeType.EndElement:
- parentForFirstChild = -1;
+ parentStackIndex--;
return;
default:
// No operations. Doctype, EntityReference,
return;
}
- parentForFirstChild = -1; // Might be changed in
ProcessElement().
-
string value = null;
XPathNodeType nodeType = XPathNodeType.Text;
@@ -352,8 +345,8 @@
private void PrepareStartElement (int previousSibling)
{
- firstAttributeIndex = 0;
- lastNsIndexInCurrent = 0;
+ hasAttributes = false;
+ hasLocalNs = false;
attrIndexAtStart = attributeIndex;
nsIndexAtStart = nsIndex;
@@ -394,21 +387,28 @@
lastNsInScope = nsIndex;
}
- if (!nodes [nodeIndex].IsEmptyElement)
- parentForFirstChild = nodeIndex;
+ if (!nodes [nodeIndex].IsEmptyElement) {
+ parentStack [++parentStackIndex] = nodeIndex;
+ if (parentStack.Length == parentStackIndex) {
+ int [] tmp = new int [parentStackIndex
* 2];
+ Array.Copy (parentStack, tmp,
parentStackIndex);
+ parentStack = tmp;
+ }
+ }
}
private void ProcessNamespace (string prefix, string ns)
{
+ int nextTmp = hasLocalNs ?
+ nsIndex : nodes [nodeIndex].FirstNamespace;
+
nsIndex++;
- int nextTmp = lastNsIndexInCurrent == 0 ? nodes
[nodeIndex].FirstNamespace : lastNsIndexInCurrent;
-
this.AddNsNode (nodeIndex,
AtomicIndex (prefix),
AtomicIndex (ns),
nextTmp);
- lastNsIndexInCurrent = nsIndex;
+ hasLocalNs = true;
}
private void ProcessAttribute (string prefix, string localName,
string ns, string value)
@@ -422,10 +422,10 @@
NonAtomicIndex (value),
lineInfo != null ? lineInfo.LineNumber : 0,
lineInfo != null ? lineInfo.LinePosition : 0);
- if (firstAttributeIndex == 0)
- firstAttributeIndex = attributeIndex;
+ if (hasAttributes)
+ attributes [attributeIndex - 1].NextAttribute =
attributeIndex;
else
- attributes [attributeIndex - 1].NextAttribute =
attributeIndex;
+ hasAttributes = true;
// Identity infoset
if (validatingReader != null) {
Modified: trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs
2005-03-15 04:26:50 UTC (rev 41822)
+++ trunk/mcs/class/System.XML/Mono.Xml.XPath/DTMXPathNavigator2.cs
2005-03-15 04:34:36 UTC (rev 41823)
@@ -228,7 +228,11 @@
return nonAtomicStringPool [nodes
[currentNode].Value];
}
- // Element
+ // Element - collect all content values
+ int iter = nodes [currentNode].FirstChild;
+ if (iter == 0)
+ return String.Empty;
+
if (valueBuilder == null)
valueBuilder = new StringBuilder ();
else
@@ -245,10 +249,6 @@
end = nodes.Length;
}
- int iter = nodes [currentNode].FirstChild;
- if (iter == 0)
- iter = end;
-
while (iter < end) {
switch (nodes [iter].NodeType) {
case XPathNodeType.Text:
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches