Author: atsushi
Date: 2005-11-07 05:37:57 -0500 (Mon, 07 Nov 2005)
New Revision: 52646

Modified:
   trunk/mcs/class/System.XML/System.Xml/ChangeLog
   trunk/mcs/class/System.XML/System.Xml/XmlAttribute.cs
   trunk/mcs/class/System.XML/System.Xml/XmlDocument.cs
   trunk/mcs/class/System.XML/System.Xml/XmlElement.cs
   trunk/mcs/class/System.XML/System.Xml/XmlNode.cs
Log:
2005-11-07  Atsushi Enomoto <[EMAIL PROTECTED]>

        * XmlAttribute.cs : added new overrides in 2.0 RTM (this scarcely
          makes sense without real optimization though).
        * XmlDocument.cs, XmlElement.cs, XmlNode.cs : avoid ChildNodes and
          save extra XmlNodeList creation cost.



Modified: trunk/mcs/class/System.XML/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/ChangeLog     2005-11-07 10:05:40 UTC 
(rev 52645)
+++ trunk/mcs/class/System.XML/System.Xml/ChangeLog     2005-11-07 10:37:57 UTC 
(rev 52646)
@@ -1,5 +1,12 @@
 2005-11-07  Atsushi Enomoto <[EMAIL PROTECTED]>
 
+       * XmlAttribute.cs : added new overrides in 2.0 RTM (this scarcely
+         makes sense without real optimization though).
+       * XmlDocument.cs, XmlElement.cs, XmlNode.cs : avoid ChildNodes and
+         save extra XmlNodeList creation cost.
+
+2005-11-07  Atsushi Enomoto <[EMAIL PROTECTED]>
+
        * XmlNamespaceManager.cs : NameTable is virtual in 2.0 RTM.
        * XmlReader.cs : IsEmptyElement is reverted to be abstract in 2.0 RTM.
          ReadTypedValue() is removed.

Modified: trunk/mcs/class/System.XML/System.Xml/XmlAttribute.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlAttribute.cs       2005-11-07 
10:05:40 UTC (rev 52645)
+++ trunk/mcs/class/System.XML/System.Xml/XmlAttribute.cs       2005-11-07 
10:37:57 UTC (rev 52646)
@@ -258,6 +258,38 @@
 
                #region Methods
 
+#if NET_2_0
+               public override XmlNode AppendChild (XmlNode child)
+               {
+                       return base.AppendChild (child);
+               }
+
+               public override XmlNode InsertBefore (XmlNode newChild, XmlNode 
refChild)
+               {
+                       return base.InsertBefore (newChild, refChild);
+               }
+
+               public override XmlNode InsertAfter (XmlNode newChild, XmlNode 
refChild)
+               {
+                       return base.InsertAfter (newChild, refChild);
+               }
+
+               public override XmlNode PrependChild (XmlNode node)
+               {
+                       return base.PrependChild (node);
+               }
+
+               public override XmlNode RemoveChild (XmlNode node)
+               {
+                       return base.RemoveChild (node);
+               }
+
+               public override XmlNode ReplaceChild (XmlNode newChild, XmlNode 
oldChild)
+               {
+                       return base.ReplaceChild (newChild, oldChild);
+               }
+#endif
+
                public override XmlNode CloneNode (bool deep)
                {
                        XmlNode node = new XmlAttribute (name.Prefix, 
name.LocalName, name.NS,

Modified: trunk/mcs/class/System.XML/System.Xml/XmlDocument.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlDocument.cs        2005-11-07 
10:05:40 UTC (rev 52645)
+++ trunk/mcs/class/System.XML/System.Xml/XmlDocument.cs        2005-11-07 
10:37:57 UTC (rev 52646)
@@ -139,11 +139,10 @@
 
                public virtual XmlDocumentType DocumentType {
                        get {
-                               for (int i = 0; i < ChildNodes.Count; i++) {
-                                       XmlNode n = ChildNodes [i];
+                               for (XmlNode n = FirstChild; n != null; n = 
n.NextSibling)
                                        if(n.NodeType == 
XmlNodeType.DocumentType)
                                                return (XmlDocumentType)n;
-                               }
+
                                return null;
                        }
                }
@@ -259,8 +258,8 @@
 
                        if(deep)
                        {
-                               for (int i = 0; i < ChildNodes.Count; i++)
-                                       doc.AppendChild (doc.ImportNode 
(ChildNodes [i], deep));
+                               for (XmlNode n = FirstChild; n != null; n = 
n.NextSibling)
+                                       doc.AppendChild (doc.ImportNode (n, 
deep));
                        }
                        return doc;
                }
@@ -536,8 +535,8 @@
                        case XmlNodeType.Attribute:
                                XmlAttribute srcAtt = node as XmlAttribute;
                                XmlAttribute dstAtt = this.CreateAttribute 
(srcAtt.Prefix, srcAtt.LocalName, srcAtt.NamespaceURI);
-                               for (int i = 0; i < srcAtt.ChildNodes.Count; 
i++)
-                                       dstAtt.AppendChild (this.ImportNode 
(srcAtt.ChildNodes [i], deep));
+                               for (XmlNode n = srcAtt.FirstChild; n != null; 
n = n.NextSibling)
+                                       dstAtt.AppendChild (this.ImportNode (n, 
deep));
                                return dstAtt;
 
                        case XmlNodeType.CDATA:
@@ -552,8 +551,8 @@
                        case XmlNodeType.DocumentFragment:
                                XmlDocumentFragment df = 
this.CreateDocumentFragment ();
                                if(deep)
-                                       for (int i = 0; i < 
node.ChildNodes.Count; i++)
-                                               df.AppendChild (this.ImportNode 
(node.ChildNodes [i], deep));
+                                       for (XmlNode n = node.FirstChild; n != 
null; n = n.NextSibling)
+                                               df.AppendChild (this.ImportNode 
(n, deep));
                                return df;
 
                        case XmlNodeType.DocumentType:
@@ -568,8 +567,8 @@
                                                dst.SetAttributeNode 
((XmlAttribute) this.ImportNode (attr, deep));
                                }
                                if(deep)
-                                       for (int i = 0; i < 
src.ChildNodes.Count; i++)
-                                               dst.AppendChild 
(this.ImportNode (src.ChildNodes [i], deep));
+                                       for (XmlNode n = src.FirstChild; n != 
null; n = n.NextSibling)
+                                               dst.AppendChild 
(this.ImportNode (n, deep));
                                return dst;
 
                        case XmlNodeType.EndElement:
@@ -958,8 +957,8 @@
 
                public override void WriteContentTo (XmlWriter w)
                {
-                       for (int i = 0; i < ChildNodes.Count; i++)
-                               ChildNodes [i].WriteTo (w);
+                       for (XmlNode n = FirstChild; n != null; n = 
n.NextSibling)
+                               n.WriteTo (w);
                }
 
                public override void WriteTo (XmlWriter w)

Modified: trunk/mcs/class/System.XML/System.Xml/XmlElement.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlElement.cs 2005-11-07 10:05:40 UTC 
(rev 52645)
+++ trunk/mcs/class/System.XML/System.Xml/XmlElement.cs 2005-11-07 10:37:57 UTC 
(rev 52646)
@@ -121,7 +121,7 @@
                        }
                        set {
                                // Why its behavior (of MS FCL) is different 
from InnerXml...?
-                               if (ChildNodes != null && ChildNodes.Count == 1 
&& FirstChild.NodeType == XmlNodeType.Text)
+                               if (FirstChild != null && 
FirstChild.NextSibling == null && FirstChild.NodeType == XmlNodeType.Text)
                                        FirstChild.Value = value;
                                else {
                                        while (FirstChild != null)

Modified: trunk/mcs/class/System.XML/System.Xml/XmlNode.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlNode.cs    2005-11-07 10:05:40 UTC 
(rev 52645)
+++ trunk/mcs/class/System.XML/System.Xml/XmlNode.cs    2005-11-07 10:37:57 UTC 
(rev 52646)
@@ -421,7 +421,7 @@
                        XmlNode argNode = null;
                        if (refChild != null)
                                argNode = refChild.NextSibling;
-                       else if (ChildNodes.Count > 0)
+                       else if (FirstChild != null)
                                argNode = FirstChild;
                        return InsertBefore (newChild, argNode);
                }
@@ -458,11 +458,15 @@
                                newChild.ParentNode.RemoveChild (newChild, 
checkNodeType);
 
                        if (newChild.NodeType == XmlNodeType.DocumentFragment) {
+                               // This recursively invokes events. (It is 
compatible with MS implementation.)
+                               while (newChild.FirstChild != null)
+                                       this.InsertBefore (newChild.FirstChild, 
refChild);
+                               /*
                                int x = newChild.ChildNodes.Count;
                                for (int i = 0; i < x; i++) {
                                        XmlNode n = newChild.ChildNodes [0];
-                                       this.InsertBefore (n, refChild);        
// recursively invokes events. (It is compatible with MS implementation.)
-                               }
+                                       this.InsertBefore (n, refChild);        
                                }
+                               */
                        }
                        else {
                                XmlLinkedNode newLinkedChild = (XmlLinkedNode) 
newChild;
@@ -728,8 +732,7 @@
 
                internal void SearchDescendantElements (string name, bool 
matchAll, ArrayList list)
                {
-                       for (int i = 0; i < ChildNodes.Count; i++) {
-                               XmlNode n = ChildNodes [i];
+                       for (XmlNode n = FirstChild; n != null; n = 
n.NextSibling) {
                                if (n.NodeType != XmlNodeType.Element)
                                        continue;
                                if (matchAll || n.Name == name)
@@ -740,8 +743,7 @@
 
                internal void SearchDescendantElements (string name, bool 
matchAllName, string ns, bool matchAllNS, ArrayList list)
                {
-                       for (int i = 0; i < ChildNodes.Count; i++) {
-                               XmlNode n = ChildNodes [i];
+                       for (XmlNode n = FirstChild; n != null; n = 
n.NextSibling) {
                                if (n.NodeType != XmlNodeType.Element)
                                        continue;
                                if ((matchAllName || n.LocalName == name)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to