Author: atsushi
Date: 2005-03-09 05:11:52 -0500 (Wed, 09 Mar 2005)
New Revision: 41591
Modified:
trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog
trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs
trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslVariable.cs
trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog
trunk/mcs/class/System.XML/System.Xml.XPath/Iterator.cs
Log:
2005-03-09 Atsushi Enomoto <[EMAIL PROTECTED]>
* XslVariable.cs : clone stored XPathNavigator items before storing.
* XslAttribute.cs : tiny code reduction.
* Iterator.cs : Now for most of iterator types, Current property always
returns the same instance. It results in huge memory reduction.
Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog
2005-03-09 10:04:11 UTC (rev 41590)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/ChangeLog
2005-03-09 10:11:52 UTC (rev 41591)
@@ -1,3 +1,8 @@
+2005-03-09 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * XslVariable.cs : clone stored XPathNavigator items before storing.
+ * XslAttribute.cs : tiny code reduction.
+
2005-03-08 Atsushi Enomoto <[EMAIL PROTECTED]>
* XslAttribute.cs : In Evaluate(), name strings are not computed as
Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs
2005-03-09 10:04:11 UTC (rev 41590)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslAttribute.cs
2005-03-09 10:11:52 UTC (rev 41591)
@@ -90,7 +90,6 @@
value = c.CompileTemplateContent
(XPathNodeType.Attribute);
c.Input.MoveToParent ();
}
-
}
public override void Evaluate (XslTransformProcessor p)
@@ -110,7 +109,7 @@
// local attribute
if (colonAt > 0) {
prefix = nm.Substring (0, colonAt);
- nm = nm.Substring (colonAt + 1, nm.Length -
colonAt - 1);
+ nm = nm.Substring (colonAt + 1);
// global attribute
if (nmsp == String.Empty &&
@@ -121,8 +120,6 @@
if (nmsp == null)
nmsp = String.Empty;
}
- else
- nm = XslNameUtil.LocalNameOf (nm);
}
if (prefix == "xmlns")
Modified: trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslVariable.cs
===================================================================
--- trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslVariable.cs
2005-03-09 10:04:11 UTC (rev 41590)
+++ trunk/mcs/class/System.XML/Mono.Xml.Xsl.Operations/XslVariable.cs
2005-03-09 10:11:52 UTC (rev 41591)
@@ -94,7 +94,7 @@
ArrayList al = new ArrayList ();
XPathNodeIterator iter =
(XPathNodeIterator) o;
while (iter.MoveNext ())
- al.Add (iter.Current);
+ al.Add (iter.Current.Clone ());
o = new ListIterator (al,
p.XPathContext, false);
}
return o;
Modified: trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog 2005-03-09
10:04:11 UTC (rev 41590)
+++ trunk/mcs/class/System.XML/System.Xml.XPath/ChangeLog 2005-03-09
10:11:52 UTC (rev 41591)
@@ -1,3 +1,8 @@
+2004-03-09 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * Iterator.cs : Now for most of iterator types, Current property always
+ returns the same instance. It results in huge memory reduction.
+
2004-03-04 Atsushi Enomoto <[EMAIL PROTECTED]>
* Iterator.cs : (SlashIterator.MoveNext()) For SortedList.Add(), the
Modified: trunk/mcs/class/System.XML/System.Xml.XPath/Iterator.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml.XPath/Iterator.cs 2005-03-09
10:04:11 UTC (rev 41590)
+++ trunk/mcs/class/System.XML/System.Xml.XPath/Iterator.cs 2005-03-09
10:11:52 UTC (rev 41591)
@@ -267,7 +267,7 @@
{
bool fSuccess = (CurrentPosition == 0) ?
_nav.MoveToFirstChild () : _nav.MoveToNext ();
if (fSuccess) {
- _current = null;
+ Current.MoveTo (_nav);
}
return fSuccess;
}
@@ -290,7 +290,7 @@
}
if (_nav.MoveToNext ())
{
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
return false;
@@ -333,7 +333,7 @@
_nav.MoveToFirst ();
if (!_nav.IsSamePosition (startPosition)) {
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
} else {
@@ -347,7 +347,7 @@
finished = true;
return false;
} else {
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
}
@@ -404,14 +404,14 @@
if (startPosition.NodeType !=
XPathNodeType.Root) {
// First time it returns Root
_nav.MoveToRoot ();
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
}
if (currentPosition == 0)
return false;
_nav.MoveTo ((XPathNavigator) navigators
[--currentPosition]);
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
@@ -476,7 +476,7 @@
if (startPosition.NodeType !=
XPathNodeType.Root) {
// First time it returns Root
_nav.MoveToRoot ();
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
}
@@ -484,11 +484,11 @@
return false;
if (currentPosition-- == 0) {
_nav.MoveTo (startPosition);
- _current = null;
+ Current.MoveTo (_nav);
return true; // returns self.
}
_nav.MoveTo ((XPathNavigator) navigators
[currentPosition]);
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
@@ -530,14 +530,14 @@
if (_nav.MoveToFirstChild ())
{
_depth ++;
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
while (_depth != 0)
{
if (_nav.MoveToNext ())
{
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
if (!_nav.MoveToParent ()) // should NEVER
fail!
@@ -573,20 +573,20 @@
if (CurrentPosition == 0)
{
// self
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
if (_nav.MoveToFirstChild ())
{
_depth ++;
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
while (_depth != 0)
{
if (_nav.MoveToNext ())
{
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
if (!_nav.MoveToParent ()) // should NEVER
fail!
@@ -623,12 +623,12 @@
default:
if (_nav.MoveToNext ())
{
- _current = null;
+ Current.MoveTo (_nav);
return true;
} else {
while (_nav.MoveToParent ()) {
if (_nav.MoveToNext ())
{
- _current = null;
+ Current.MoveTo
(_nav);
return true;
}
}
@@ -640,14 +640,14 @@
{
if (_nav.MoveToFirstChild ())
{
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
do
{
if (_nav.MoveToNext ())
{
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
}
@@ -706,7 +706,7 @@
finished = true;
return false;
} else {
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
}
@@ -728,13 +728,13 @@
{
if (_nav.MoveToFirstNamespace ())
{
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
}
else if (_nav.MoveToNextNamespace ())
{
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
return false;
@@ -755,13 +755,13 @@
{
if (_nav.MoveToFirstAttribute ())
{
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
}
else if (_nav.MoveToNextAttribute ())
{
- _current = null;
+ Current.MoveTo (_nav);
return true;
}
return false;
@@ -971,7 +971,7 @@
_iterRight = _expr.EvaluateNodeSet
(_iterLeft);
}
XPathNavigator nav = _iterRight.Current;
- _navStore.Add (nav);
+ _navStore.Add (nav.Clone ());
}
}
@@ -1113,7 +1113,7 @@
private BaseIterator _left, _right;
private bool keepLeft;
private bool keepRight;
- private bool useRight;
+ XPathNavigator _current;
public UnionIterator (BaseIterator iter, BaseIterator left,
BaseIterator right) : base (iter.NamespaceManager)
{
@@ -1127,7 +1127,8 @@
_right = (BaseIterator) other._right.Clone ();
keepLeft = other.keepLeft;
keepRight = other.keepRight;
- useRight = other.useRight;
+ if (other._current != null)
+ _current = other._current.Clone ();
}
public override XPathNodeIterator Clone () { return new
UnionIterator (this); }
@@ -1142,11 +1143,12 @@
return false;
if (!keepRight) {
- keepLeft = useRight = false;
+ keepLeft = false;
+ SetCurrent (_left);
return true;
} else if (!keepLeft) {
keepRight = false;
- useRight = true;
+ SetCurrent (_right);
return true;
}
@@ -1154,31 +1156,33 @@
case XmlNodeOrder.Same:
// consume both. i.e. don't output duplicate
result.
keepLeft = keepRight = false;
- useRight = true;
+ SetCurrent (_right);
return true;
case XmlNodeOrder.Before:
case XmlNodeOrder.Unknown: // Maybe happen because of
"document(a) | document(b)"
- keepLeft = useRight = false;
+ keepLeft = false;
+ SetCurrent (_left);
return true;
case XmlNodeOrder.After:
keepRight = false;
- useRight = true;
+ SetCurrent (_right);
return true;
default:
throw new InvalidOperationException ("Should
not happen.");
}
}
+
+ private void SetCurrent (XPathNodeIterator iter)
+ {
+ if (_current == null)
+ _current = iter.Current.Clone ();
+ else
+ _current.MoveTo (iter.Current);
+ }
+
public override XPathNavigator Current
{
- get
- {
- if (CurrentPosition == 0)
- return null;
- if (useRight)
- return _right.Current;
- else
- return _left.Current;
- }
+ get { return _current; }
}
public override bool RequireSorting { get { return
_left.RequireSorting || _right.RequireSorting; } }
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches