2009-12-04 UPDATE: For profiling results on a number of the suggestions posted here, see below!
Consider the following very
I'd extrapolate tster's reply to "switch over a custom hash function", assuming that the code generator creates a lookup table, or - failing that - building the lookup table myself.
The custom hash function should be simple, e.g.:
(int)ActivCode[0]*2 + ActivCode.Length-1
This would require a table of 51 elements, easily kept in L1 cache, under the following assumptions:
the empty string case could be incorporated if you could use an unsafe access to ActivCode[0]
yielding the '\0' terminator.
I'd use a dictionary for the key value pairs and take advantage of the O(1) lookup time.
+1 for using a dictionary. Not necessarily for optimization, but it'd be cleaner.
I would probably use constants for the strings as well, though i doubt that'd buy you anything performance wise.