[Mono-bugs] [Bug 55979][Wis] New - We can avoid a local variable in foreach
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Tue, 23 Mar 2004 18:52:36 -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=55979
--- shadow/55979 2004-03-23 18:52:36.000000000 -0500
+++ shadow/55979.tmp.19935 2004-03-23 18:52:36.000000000 -0500
@@ -0,0 +1,49 @@
+Bug#: 55979
+Product: Mono: Compilers
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: bmaurer@users.sf.net
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Summary: We can avoid a local variable in foreach
+
+The attached patch changes us from using code like:
+
+ IL_002e: ldloc.2
+ IL_002f: isinst [mscorlib]System.IDisposable
+ IL_0034: stloc.3
+ IL_0035: ldloc.3
+ IL_0036: brfalse IL_0041
+
+ IL_003b: ldloc.3
+ IL_003c: callvirt instance void class
+[mscorlib]'System.IDisposable'::'Dispose'()
+ IL_0041: endfinally
+
+in the finally section of a foreach loop to using:
+
+ IL_002e: ldloc.2
+ IL_002f: isinst [mscorlib]System.IDisposable
+ IL_0034: dup
+ IL_0035: brtrue.s IL_0039
+
+ IL_0037: pop
+ IL_0038: endfinally
+ IL_0039: callvirt instance void class
+[mscorlib]'System.IDisposable'::'Dispose'()
+ IL_003e: endfinally
+
+Not only is this IL code itself smaller, but it also avoids a local variable.
+
+I ran all the mcs tests, and as well ran peverify on mcs2.exe (from btest),
+and it passed.
+
+Martin, I would love your review again :-).