[Mono-bugs] [Bug 354238] New: Future Optimization: Use Dictionary<string, int> for switch on string

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Jan 16 13:12:12 EST 2008


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: mono-bugs at lists.ximian.com
        ReportedBy: juraj at hotfeet.ch
         QAContact: mono-bugs at lists.ximian.com
          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.


More information about the mono-bugs mailing list