diff options
author | Marek Habersack <grendel@twistedcode.net> | 2008-02-28 19:21:29 +0300 |
---|---|---|
committer | Marek Habersack <grendel@twistedcode.net> | 2008-02-28 19:21:29 +0300 |
commit | 2b3bfcb002d9e7dc8b5bb9e93d5416fa3a7f4a24 (patch) | |
tree | 9b9e872f956e465de552504df374fe61e9f9a8b9 | |
parent | 23a247a942a996fb4e7ab886d09cf42069aa681d (diff) |
Backport of some changes from svn trunk - performance improvement and a fix for bug #325371mono-1-9-p3
svn path=/branches/mono-1-9/mcs/; revision=96899
4 files changed, 60 insertions, 10 deletions
diff --git a/mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog b/mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog index e6f5f55247c..10ef50e8af7 100644 --- a/mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog +++ b/mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog @@ -8,6 +8,11 @@ * BuildProviderCollection.cs: be case-insensitive when looking for the extension match. +2008-02-18 Vladimir Krasnov <vladimirk@mainsoft.com> + + * WebConfigurationManager.cs: performance improvement, cached + GetSection method + 2008-02-05 Marek Habersack <mhabersack@novell.com> * CompilerCollection.cs: Get (string language) should not use diff --git a/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs b/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs index 40471615bf2..8470fb909f2 100644 --- a/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs +++ b/mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs @@ -47,8 +47,9 @@ namespace System.Web.Configuration { #if !TARGET_J2EE static IInternalConfigConfigurationFactory configFactory; static Hashtable configurations = Hashtable.Synchronized (new Hashtable ()); + static Hashtable sectionCache = new Hashtable (StringComparer.OrdinalIgnoreCase); #else - static readonly object AppSettingsKey = new object (); + const string AppSettingsKey = "WebConfigurationManager.AppSettings"; static internal IInternalConfigConfigurationFactory configFactory { get{ @@ -94,6 +95,23 @@ namespace System.Web.Configuration { AppDomain.CurrentDomain.SetData("WebConfigurationManager.configurations.initialized", true); } } + + static Hashtable sectionCache + { + get + { + Hashtable sectionCache = (Hashtable) AppDomain.CurrentDomain.GetData ("sectionCache"); + if (sectionCache == null) { + sectionCache = new Hashtable (StringComparer.OrdinalIgnoreCase); + AppDomain.CurrentDomain.SetData ("sectionCache", sectionCache); + } + return sectionCache; + } + set + { + AppDomain.CurrentDomain.SetData ("sectionCache", value); + } + } #endif static ArrayList extra_assemblies = null; @@ -266,6 +284,10 @@ namespace System.Web.Configuration { public static object GetSection (string sectionName, string path) { + object cachedSection = sectionCache [GetSectionCacheKey (sectionName, path)]; + if (cachedSection != null) + return cachedSection; + _Configuration c = OpenWebConfiguration (path); ConfigurationSection section = c.GetSection (sectionName); @@ -275,20 +297,17 @@ namespace System.Web.Configuration { #if TARGET_J2EE object value = get_runtime_object.Invoke (section, new object [0]); if (String.CompareOrdinal ("appSettings", sectionName) == 0) { - HttpContext hc = HttpContext.Current; - NameValueCollection collection = (NameValueCollection) hc.Items [AppSettingsKey]; - - if (collection == null) { - collection = new KeyValueMergedCollection (hc, (NameValueCollection) value); - hc.Items [AppSettingsKey] = collection; - } - + NameValueCollection collection; + collection = new KeyValueMergedCollection (HttpContext.Current, (NameValueCollection) value); value = collection; } + AddSectionToCache (GetSectionCacheKey (sectionName, path), value); return value; #else - return SettingsMappingManager.MapSection (get_runtime_object.Invoke (section, new object [0])); + object value = SettingsMappingManager.MapSection (get_runtime_object.Invoke (section, new object [0])); + AddSectionToCache (GetSectionCacheKey (sectionName, path), value); + return value; #endif } @@ -326,6 +345,25 @@ namespace System.Web.Configuration { internal static IInternalConfigConfigurationFactory ConfigurationFactory { get { return configFactory; } } + + static void AddSectionToCache (string key, object section) + { + if (sectionCache [key] != null) + return; + + Hashtable tmpTable = (Hashtable) sectionCache.Clone (); + if (tmpTable.Contains (key)) + return; + + tmpTable.Add (key, section); + sectionCache = tmpTable; + } + + static string GetSectionCacheKey (string sectionName, string path) + { + return string.Concat (path, "/", sectionName); + } + #region stuff copied from WebConfigurationSettings #if TARGET_J2EE diff --git a/mcs/class/System.Web/System.Web/ChangeLog b/mcs/class/System.Web/System.Web/ChangeLog index 17ebcb2d48b..d1c45cdbf3a 100644 --- a/mcs/class/System.Web/System.Web/ChangeLog +++ b/mcs/class/System.Web/System.Web/ChangeLog @@ -58,6 +58,10 @@ Watch for Created event in the FileSystemWatcher for the app_offline.htm files. +2008-01-29 Vladimir Krasnov <vladimirk@mainsoft.com> + + * HttpRequest.cs: performance optimization of QueryStringRaw + 2008-01-27 Igor Zelmanovich <igorz@mainsoft.com> * HttpResponse.cs: rise PreSendRequestHeaders befire headers_sent diff --git a/mcs/class/System.Web/System.Web/HttpRequest.cs b/mcs/class/System.Web/System.Web/HttpRequest.cs index 00e2002f459..f2e4744fa5d 100644 --- a/mcs/class/System.Web/System.Web/HttpRequest.cs +++ b/mcs/class/System.Web/System.Web/HttpRequest.cs @@ -1337,6 +1337,9 @@ namespace System.Web { // Notice: there is nothing raw about this querystring. internal string QueryStringRaw { get { + if (url_components == null) + return worker_request.GetQueryString (); + return UrlComponents.Query; } |