Просмотр исходного кода

2004-02-08 Atsushi Enomoto <[email protected]>

	* GenericOutputter.cs,
	  XslAttributeSet.cs,
	  XslStylesheet.cs,
	  XslTemplate.cs : tiny foreach elimination.

svn path=/trunk/mcs/; revision=22890
Atsushi Eno 22 лет назад
Родитель
Сommit
e94468c53c

+ 7 - 0
mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog

@@ -1,3 +1,10 @@
+2004-02-08 Atsushi Enomoto <[email protected]>
+
+	* GenericOutputter.cs,
+	  XslAttributeSet.cs,
+	  XslStylesheet.cs,
+	  XslTemplate.cs : tiny foreach elimination.
+
 2004-01-16 Atsushi Enomoto <[email protected]>
 
 	* XslOutput.cs : Reverted. default encoding should be utf-8.

+ 5 - 3
mcs/class/System.XML/Mono.Xml.Xsl/GenericOutputter.cs

@@ -10,6 +10,7 @@
 
 using System;
 using System.Collections;
+using System.Collections.Specialized;
 using System.Xml;
 using System.IO;
 using System.Text;
@@ -42,7 +43,7 @@ namespace Mono.Xml.Xsl
 		int pendingAttributesPos = 0;
 		//Namespace manager. Subject to optimization.
 		private XmlNamespaceManager _nsManager;
-		private ArrayList _currentNsPrefixes;
+		private StringCollection _currentNsPrefixes;
 		private Hashtable _currentNamespaceDecls;
 		//Name table
 		private NameTable _nt;
@@ -62,7 +63,7 @@ namespace Mono.Xml.Xsl
 			//TODO: Optimize using nametable
 			_nt = new NameTable ();
 			_nsManager = new XmlNamespaceManager (_nt);
-			_currentNsPrefixes = new ArrayList ();
+			_currentNsPrefixes = new StringCollection ();
 			_currentNamespaceDecls = new Hashtable ();
 		}
 
@@ -152,7 +153,8 @@ namespace Mono.Xml.Xsl
 						prefix = _nsManager.LookupPrefix (attr.Namespace);
 					Emitter.WriteAttributeString (prefix, attr.LocalName, attr.Namespace, attr.Value);
 				}
-				foreach (string prefix in _currentNsPrefixes) {
+				for (int i = 0; i < _currentNsPrefixes.Count; i++) {
+					string prefix = _currentNsPrefixes [i];
 					string uri = _currentNamespaceDecls [prefix] as string;
 					if (prefix != String.Empty)
 						Emitter.WriteAttributeString ("xmlns", prefix, XmlNamespaceManager.XmlnsXmlns, uri);

+ 4 - 4
mcs/class/System.XML/Mono.Xml.Xsl/XslAttributeSet.cs

@@ -82,8 +82,8 @@ namespace Mono.Xml.Xsl {
 			p.SetBusy (this);
 			
 			if (usedAttributeSets != null) {
-				foreach (QName set in usedAttributeSets)
-				{
+				for (int i = 0; i < usedAttributeSets.Count; i++) {
+					QName set = (QName) usedAttributeSets [i];
 					XslAttributeSet s = p.ResolveAttributeSet (set);
 					if (s == null)
 						throw new XsltException ("Could not resolve attribute set", null, p.CurrentNode);
@@ -95,8 +95,8 @@ namespace Mono.Xml.Xsl {
 				}
 			}
 						
-			foreach (Operations.XslAttribute a in attributes)
-				a.Evaluate (p);
+			for (int i = 0; i < attributes.Count; i++)
+				((XslAttribute) attributes [i]).Evaluate (p);
 			
 			p.SetFree (this);
 		}

+ 9 - 8
mcs/class/System.XML/Mono.Xml.Xsl/XslStylesheet.cs

@@ -184,8 +184,9 @@ namespace Mono.Xml.Xsl {
 			XmlQualifiedName qname = new XmlQualifiedName (localName, ns);
 			object o = spaceControls [qname];
 			if (o == null) {
-				foreach (XslStylesheet s in imports) {
-					o = s.SpaceControls [qname];
+
+				for (int i = 0; i < imports.Count; i++) {
+					o = ((XslStylesheet) imports [i]).SpaceControls [qname];
 					if (o != null)
 						break;
 				}
@@ -195,8 +196,8 @@ namespace Mono.Xml.Xsl {
 				qname = new XmlQualifiedName ("*", ns);
 				o = spaceControls [qname];
 				if (o == null) {
-					foreach (XslStylesheet s in imports) {
-						o = s.SpaceControls [qname];
+					for (int i = 0; i < imports.Count; i++) {
+						o = ((XslStylesheet) imports [i]).SpaceControls [qname];
 						if (o != null)
 							break;
 					}
@@ -207,8 +208,8 @@ namespace Mono.Xml.Xsl {
 				qname = new XmlQualifiedName ("*", String.Empty);
 				o = spaceControls [qname];
 				if (o == null) {
-					foreach (XslStylesheet s in imports) {
-						o = s.SpaceControls [qname];
+					for (int i = 0; i < imports.Count; i++) {
+						o = ((XslStylesheet) imports [i]).SpaceControls [qname];
 						if (o != null)
 							break;
 					}
@@ -255,8 +256,8 @@ namespace Mono.Xml.Xsl {
 
 			string result = namespaceAliases [prefix];
 			if (result == null) {
-				foreach (XslStylesheet s in imports) {
-					result = s.namespaceAliases [prefix];
+				for (int i = 0; i < imports.Count; i++) {
+					result = ((XslStylesheet) imports [i]).namespaceAliases [prefix];
 					if (result != null)
 						break;
 				}

+ 3 - 1
mcs/class/System.XML/Mono.Xml.Xsl/XslTemplate.cs

@@ -116,9 +116,11 @@ namespace Mono.Xml.Xsl {
 				sorted = true;
 			}
 			
-			foreach (TemplateWithPriority t in this.unnamedTemplates)
+			for (int i = 0; i < unnamedTemplates.Count; i++) {
+				TemplateWithPriority t = (TemplateWithPriority) unnamedTemplates [i];
 				if (t.Matches (node, p))
 					return t.Template;
+			}
 
 			return null;
 		}