[Mono-devel-list] mcs code for switches on strings

Marcus mathpup at mylinuxisp.com
Sun Mar 21 17:53:52 EST 2004


On Sunday 21 March 2004 3:37 pm, Paolo Molaro wrote:

Currently, cscc uses different implementations for switches depending on the 
number of cases. I don't have the exact details handy. I also brought up this 
issue with Rhys, and he said that he's working on writing some test programs 
that are more thorough than mine. (My short program fails to intern a large 
number of different strings, and the few strings present are comparatively 
short.)

These tests might useful be useful on Mono, so I will post here if I can 
obtain any test programs that might be released.

> Currently IsInterned () is a little expensive, so for a small number of
> cases it dominates the runtime. The current implementation could be
> improved a little, or we could write a different one and see how it
> performs. Note that on the MS runtime you'll get beasically the same
> numbers (at least on .Net 1.0, dunno if they optimized it later).
> There are a number of strategies to implement switch on strings:
> 1) ifs with String.Equals ()
> 2) ifs after IsInterned ()
> 3) binary search
> 4) hashtable + switch on number



More information about the Mono-devel-list mailing list