From 5d250224236e6a6cd7022ba9cdb93a5fdb842004 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Tue, 8 Oct 2013 01:25:51 +0900 Subject: [PATCH] reduce memory use on Attribute() caused by Attributes(). --- mcs/class/System.Xml.Linq/System.Xml.Linq/XElement.cs | 3 ++- mcs/class/System.Xml.Linq/System.Xml.Linq/XName.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mcs/class/System.Xml.Linq/System.Xml.Linq/XElement.cs b/mcs/class/System.Xml.Linq/System.Xml.Linq/XElement.cs index 70b6430929a..81dea5e4a43 100644 --- a/mcs/class/System.Xml.Linq/System.Xml.Linq/XElement.cs +++ b/mcs/class/System.Xml.Linq/System.Xml.Linq/XElement.cs @@ -382,7 +382,8 @@ namespace System.Xml.Linq public XAttribute Attribute (XName name) { - foreach (XAttribute a in Attributes ()) + XAttribute next; + for (XAttribute a = attr_first; a != null; a = a.NextAttribute) if (a.Name == name) return a; return null; diff --git a/mcs/class/System.Xml.Linq/System.Xml.Linq/XName.cs b/mcs/class/System.Xml.Linq/System.Xml.Linq/XName.cs index 80d0e7b09cb..59bbceb4f92 100644 --- a/mcs/class/System.Xml.Linq/System.Xml.Linq/XName.cs +++ b/mcs/class/System.Xml.Linq/System.Xml.Linq/XName.cs @@ -153,7 +153,7 @@ namespace System.Xml.Linq public override string ToString () { - if (ns == XNamespace.None) + if (Object.ReferenceEquals (ns, XNamespace.None)) return local; return String.Concat ("{", ns.NamespaceName, "}", local); } -- 2.25.1