Optimizations in character class