[Mono-bugs] [Bug 53009][Wis] New - Strings in attribute ctors are not interned

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 17 Jan 2004 23:14:17 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bmaurer@users.sf.net.

http://bugzilla.ximian.com/show_bug.cgi?id=53009

--- shadow/53009	2004-01-17 23:14:17.000000000 -0500
+++ shadow/53009.tmp.24861	2004-01-17 23:14:17.000000000 -0500
@@ -0,0 +1,47 @@
+Bug#: 53009
+Product: Mono/Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Strings in attribute ctors are not interned
+
+In this code:
+
+using System;
+
+class Description : Attribute {
+	string s;
+	public Description (string s) { this.s = s; }
+	
+	public string Value { get { return s; } }
+}
+
+[Description ("supercalifragilisticexpialidocious")]
+class DemoClass {
+	static void Main ()
+	{
+		for (int i = 0; i < 50000; i ++) {
+			foreach (Attribute attr in Attribute.GetCustomAttributes (typeof
+(DemoClass))) {
+				// la la la la
+			}
+		}
+	}
+}
+
+under the profile, you will see many string objects being created. Only one
+should be created, on the first access, the others should come from the
+intern pool. Also, there are many other optimizations that can be made to
+this method to make it go faster, see the allocation profile, it should be
+much smaller ;-).