Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@veritas-vos-liberabit.com>2013-10-07 20:57:17 +0400
committerAtsushi Eno <atsushieno@veritas-vos-liberabit.com>2013-10-07 20:57:17 +0400
commit8d401cb39dcd5e37b65f506e810df78028e8df4a (patch)
treeef8a0b8c42544783cf8501e66aa3a18c1b4ad324 /mcs/class/System.Xml.Linq
parenta601831f63a9d29741a02aad200bf28aa6e71413 (diff)
Element() and Elements() could also reduce use of extraneous iterators.
Diffstat (limited to 'mcs/class/System.Xml.Linq')
-rw-r--r--mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs12
1 files changed, 8 insertions, 4 deletions
diff --git a/mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs b/mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs
index f38458ca3b8..af5fd976403 100644
--- a/mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs
+++ b/mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs
@@ -181,16 +181,20 @@ namespace System.Xml.Linq
public IEnumerable <XElement> Elements (XName name)
{
- foreach (XElement el in Elements ())
- if (el.Name == name)
+ foreach (XNode n in Nodes ()) {
+ XElement el = n as XElement;
+ if (el != null && el.Name == name)
yield return el;
+ }
}
public XElement Element (XName name)
{
- foreach (XElement el in Elements ())
- if (el.Name == name)
+ foreach (XNode n in Nodes ()) {
+ XElement el = n as XElement;
+ if (el != null && el.Name == name)
return el;
+ }
return null;
}