Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Backport of some changes from svn trunk - performance improvement and…

… a fix for bug #325371

svn path=/branches/mono-1-9/mcs/; revision=96899
  • Loading branch information...
commit 2b3bfcb002d9e7dc8b5bb9e93d5416fa3a7f4a24 1 parent 23a247a
@grendello grendello authored
View
5 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
View
58 mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationManager.cs
@@ -47,8 +47,9 @@ public static class WebConfigurationManager
#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 @@ static internal Hashtable configurations
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 @@ public static object GetSection (string sectionName)
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 @@ public static object GetSection (string sectionName, string path)
#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 @@ public static object GetWebApplicationSection (string sectionName)
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
View
4 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
View
3  mcs/class/System.Web/System.Web/HttpRequest.cs
@@ -1337,6 +1337,9 @@ internal void SetHeader (string name, string value)
// Notice: there is nothing raw about this querystring.
internal string QueryStringRaw {
get {
+ if (url_components == null)
+ return worker_request.GetQueryString ();
+
return UrlComponents.Query;
}
Please sign in to comment.
Something went wrong with that request. Please try again.