Add support for multiple char classes in FindFirstChars (#2254)
* Add a "multi first" check for FindFirstChars
FindFirstChars already has multiple things it checks for:
- If the expression is anchored, it checks the current position for that anchor.
- If we were able to compute a min required length, it checks for that much space remaining.
- If we were able to analyze the expression and come up with a string of text of multiple characters that must be at the beginning of any expression, we use Boyer-Moore to find it.
- If we were able to analyze the expression to come up with a character class that must match the first character in the input, we iterate through looking for that (and if possible, use IndexOf{Any} to speed that along).
This PR extends that last check to try to create a character class not just for the first character in the input, but for the first N characters in the input. The check isn't as robust, mainly focused on expressions beginning with an alternation (often when it's global), so it's a separate check we try first, and only fall back to the more robust single-class analysis if we were unsuccessful.
By checking multiple characters, we're able to stay in a tighter loop inside of FindFirstChars. In the future, we could look at replacing this with something potentially even better, such as a vectorized search for multiple starting strings.
* Address PR feedback
12 files changed: