Ver código fonte

2008-06-30 Zoltan Varga <[email protected]>

	* CapabilitiesResult.cs: Make the RandomRoboBotKeywords array static and compute it
	only once.

svn path=/trunk/mcs/; revision=106942
Zoltan Varga 17 anos atrás
pai
commit
eced772f23

+ 12 - 8
mcs/class/System.Web/System.Web.Configuration_2.0/CapabilitiesResult.cs

@@ -26,10 +26,13 @@ namespace System.Web.Configuration
 	using System;
 	using System.Collections.Generic;
 	using System.Text;
+	using System.Reflection;
+	using System.IO;
 
 	internal class CapabilitiesResult : System.Web.HttpBrowserCapabilities
 	{
-		private string[] RandomRoboBotKeywords;
+		private static string[] RandomRoboBotKeywords;
+
 		/// <summary>
 		/// Initializes a new instance of the Result class.
 		/// </summary>
@@ -40,20 +43,21 @@ namespace System.Web.Configuration
 			: base()
 		{
 			base.Capabilities = items;
+		}
 
+		static CapabilitiesResult () {
 			//---------------------------------------------------------------
 			//Copies out a list of keywords stored in an Embeded file, which 
 			//will be used to help determine if a browser is 
 			//IsRandomRoboBotUserAgent.
 			//---------------------------------------------------------------
-			System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
-			System.IO.Stream CP;
-			CP = asm.GetManifestResourceStream("RandomRoboBotKeywords.txt");
-			System.IO.StreamReader Read = new System.IO.StreamReader(CP, System.Text.Encoding.Default);
-			RandomRoboBotKeywords = System.Text.RegularExpressions.Regex.Split(Read.ReadToEnd(), System.Environment.NewLine);
-			Read.Close();
-			Read = null;
+			Assembly asm = Assembly.GetExecutingAssembly();
+			Stream CP = asm.GetManifestResourceStream("RandomRoboBotKeywords.txt");
+			using (StreamReader Read = new StreamReader(CP, System.Text.Encoding.Default)) {
+				RandomRoboBotKeywords = System.Text.RegularExpressions.Regex.Split(Read.ReadToEnd(), System.Environment.NewLine);
+			}
 		}
+
 		/// <summary>
 		/// 
 		/// </summary>

+ 5 - 0
mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog

@@ -1,3 +1,8 @@
+2008-06-30  Zoltan Varga  <[email protected]>
+
+	* CapabilitiesResult.cs: Make the RandomRoboBotKeywords array static and compute it
+	only once.
+
 2008-06-30  Marek Habersack  <[email protected]>
 
 	* CompilationSection.cs: hush the warnings