[Mono-devel-list] PROPOSED PATCH: TemplateControlParser caching

eric lindvall eric at 5stops.com
Tue Jan 27 18:20:15 EST 2004


I was profiling the ASP.NET code and found that the PageParser spent a lot
of time recreating the same objects and added some caching and found a
good performance boost.

Input on this patch is welcome.

e.


-------------- next part --------------
Index: class/System.Web/System.Web.UI/TemplateControlParser.cs
===================================================================
RCS file: /mono/mcs/class/System.Web/System.Web.UI/TemplateControlParser.cs,v
retrieving revision 1.17
diff -u -p -u -r1.17 TemplateControlParser.cs
--- class/System.Web/System.Web.UI/TemplateControlParser.cs	13 Jan 2004 21:21:27 -0000	1.17
+++ class/System.Web/System.Web.UI/TemplateControlParser.cs	28 Jan 2004 00:25:51 -0000
@@ -12,6 +12,7 @@ using System.IO;
 using System.Reflection;
 using System.Web.Compilation;
 using System.Web.Util;
+using System.Web.Caching;
 
 namespace System.Web.UI
 {
@@ -36,9 +37,21 @@ namespace System.Web.UI
 
 		internal object GetCompiledInstance ()
 		{
-			Type type = CompileIntoType ();
-			if (type == null)
-				return null;
+                        Type type = (Type) 
+                                HttpRuntime.Cache.Get (this.InputFile);
+
+                        if (type == null)
+                        {
+                                type = CompileIntoType ();
+
+                                if (type == null)
+                                        return null;
+
+                                CacheDependency cd = new CacheDependency ((string[]) 
+                                                this.Dependencies.ToArray (typeof (string)));
+
+                                HttpRuntime.Cache.Insert (this.InputFile, type, cd);
+                        }
 
 			object ctrl = Activator.CreateInstance (type);
 			if (ctrl == null)


More information about the Mono-devel-list mailing list