https://bugzilla.novell.com/show_bug.cgi?id=442122


           Summary: Better handling of read-only method variables which
                    appear in closures.
           Product: Mono: Compilers
           Version: 2.0
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: P5 - None
         Component: C#
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]
         QAContact: [email protected]
          Found By: ---


Test Case:

void Foo(int i)
{
    DoSomethingWithADelagate (() => i != 5);
    DoSomethindWithAnInt (i);
}

Observed Behaviour:

The compiler passes the captured value to DoSomethindWithAnInt. This involves
two IL instructions: ldloc (to load the instance of the compiler-generated
class) and ldfld (to load the captured value).

Expected Behaviour:

Because the argument is never assigned to or used as an out or ref parameter,
it is guaranteed not to change. The compiler should load the argument value
directly with a single ldarg instruction. The same could be done with local
variables that are not assigned to within or after their appearance in an
anonymous method.

Side Note: csc does not have this optimization.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to