Fast version of str2type using perfect hashing function.