Improve RegexOptions.Compiled codegen for ignoring case (in particular InvariantCulture) (#714)
* Remove unused RegexCompiler helpers
* Fix FindFirstChar to update runtextpos in the case of failure
I introduced this in a previous PR; by not updating the position in the case of failure, we end up potentially retrying some of the same text repeatedly.
* Improve codegen for FindFirstChar
For the common case of left-to-right, we can use a span to improve the code gen, which helps when there are multiple characters until the start of the regex.
* Optimize IgnoreCase and InvariantCulture codegen
We can improve our codegen for EmiCallCharInClass by avoiding the need to call char.ToLower{Invariant} in a variety of situations. If the character class is one for which we already generate a check that handles case appropriately (e.g. using char.IsDigit for \d), there's no need to generate a ToLower call, regardless of culture. And if we're using InvariantCulture, we can build the invariance into our generated lookup table, which means we only actually need the ToLowerInvariant call if the input isn't ASCII and we have to fall back to doing an actual CharInClass call.
* Fix stale comments
* Use rem.un instead of rem for timeout check
When a timeout is set, we try to avoid lots of CheckTimeout calls by only doing the call once every 2048 occurrences. That check is currently done with a signed % operation; the codegen code for an unsigned % operation is better, and that's all we need. We also don't need to explicitly compare to 0, and can just use brtrue on the rem.un result.
* Fix stylistic issues cited in code reviews
- Renamed all RegexCompiler static fields to be consistently named after the fields they represent
- Renamed some methods that were using acronyms
- Renamed LocalBuilers to be named consistently after the fields they mirror, and also to use consistent suffixes
- Fixed some comments
- Removed use of Enum.HasFlag to be consistent with bit flags checks elsewhere