diff options
Diffstat (limited to 'mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs')
-rw-r--r-- | mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs b/mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs index 10b51f826f3..37b147954f8 100644 --- a/mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs +++ b/mcs/class/System.XML/System.Xml/XmlNamedNodeMap.cs @@ -37,8 +37,6 @@ namespace System.Xml { public class XmlNamedNodeMap : IEnumerable { - static readonly IEnumerator emptyEnumerator = new XmlNode [0].GetEnumerator (); - XmlNode parent; ArrayList nodeList; bool readOnly = false; @@ -46,32 +44,20 @@ namespace System.Xml internal XmlNamedNodeMap (XmlNode parent) { this.parent = parent; - } - - private ArrayList NodeList { - get { - if (nodeList == null) - nodeList = new ArrayList (); - return nodeList; - } + nodeList = new ArrayList (); } public virtual int Count { - get { return nodeList == null ? 0 : nodeList.Count; } + get { return nodeList.Count; } } public virtual IEnumerator GetEnumerator () { - if (nodeList == null) - return emptyEnumerator; return nodeList.GetEnumerator (); } public virtual XmlNode GetNamedItem (string name) { - if (nodeList == null) - return null; - for (int i = 0; i < nodeList.Count; i++) { XmlNode node = (XmlNode) nodeList [i]; if (node.Name == name) @@ -82,9 +68,6 @@ namespace System.Xml public virtual XmlNode GetNamedItem (string localName, string namespaceURI) { - if (nodeList == null) - return null; - for (int i = 0; i < nodeList.Count; i++) { XmlNode node = (XmlNode) nodeList [i]; if ((node.LocalName == localName) @@ -97,7 +80,7 @@ namespace System.Xml public virtual XmlNode Item (int index) { - if (nodeList == null || index < 0 || index >= nodeList.Count) + if (index < 0 || index >= nodeList.Count) return null; else return (XmlNode) nodeList [index]; @@ -105,9 +88,6 @@ namespace System.Xml public virtual XmlNode RemoveNamedItem (string name) { - if (nodeList == null) - return null; - for (int i = 0; i < nodeList.Count; i++) { XmlNode node = (XmlNode) nodeList [i]; if (node.Name == name) { @@ -135,9 +115,6 @@ namespace System.Xml public virtual XmlNode RemoveNamedItem (string localName, string namespaceURI) { - if (nodeList == null) - return null; - for (int i = 0; i < nodeList.Count; i++) { XmlNode node = (XmlNode) nodeList [i]; if ((node.LocalName == localName) @@ -168,7 +145,7 @@ namespace System.Xml parent.OwnerDocument.onNodeInserting (node, parent); try { - for (int i = 0; i < NodeList.Count; i++) { + for (int i = 0; i < nodeList.Count; i++) { XmlNode x = (XmlNode) nodeList [i]; if(x.LocalName == node.LocalName && x.NamespaceURI == node.NamespaceURI) { nodeList.Remove (x); @@ -185,8 +162,6 @@ namespace System.Xml else nodeList.Insert (pos, node); - // LAMESPEC: It should return null here, but - // it just returns the input node. return node; } finally { if (raiseEvent) @@ -195,6 +170,6 @@ namespace System.Xml } - internal ArrayList Nodes { get { return NodeList; } } + internal ArrayList Nodes { get { return nodeList; } } } } |