[mono/mono] 8d401cb3: Element() and Elements() could also reduce use of extraneous iterators.
| Newsgroups | gmane.comp.gnome.mono.patches |
|---|---|
| Message-ID | <0000014193dc0c02-6484794f-d20e-4361-9a51-1b3c1e54f83f-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/mono
Compare: https://github.com/mono/mono/compare/a601831f63a9...8d401cb39dcd
Commit: 8d401cb39dcd5e37b65f506e810df78028e8df4a
Author: Atsushi Eno <[email protected]> (atsushieno)
Date: 2013-10-07 16:57:17 GMT
URL: https://github.com/mono/mono/commit/8d401cb39dcd5e37b65f506e810df78028e8df4a
Element() and Elements() could also reduce use of extraneous iterators.
Changed paths:
M mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs
Modified: mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs
===================================================================
@@ -181,16 +181,20 @@ public IEnumerable<XNode> DescendantNodes ()
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;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches