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


           Summary: Future Optimization: Use Dictionary<string,int> for
                    switch on string
           Product: Mono: Compilers
           Version: SVN
          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: ---


Created an attachment (id=190742)
 --> (https://bugzilla.novell.com/attachment.cgi?id=190742)
test case

Attached you'll find a simple C# program using a switch() on string.

- gmcs emits code equivalent to a chain of if-else statements
- csc emits the construction and initialization of a static
Dictionary<string,int> object, and the switch opcode which uses the output of
Dictionary<string,int>.TryGetValue.

The CIL generated by gmcs and csc is attached as well.

Issuing  'find -name "*.cs" | grep -v "Test" | xargs grep "case \""' in
mcs/class will give you a rough idea how often a switch() on strings (with many
case-values) is used (and whether it's worthwhile to implement 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