Use IndexOf for .* in RegexInterpreter/Compiler (#31930)
authorStephen Toub <stoub@microsoft.com>
Sat, 8 Feb 2020 13:52:12 +0000 (08:52 -0500)
committerGitHub <noreply@github.com>
Sat, 8 Feb 2020 13:52:12 +0000 (08:52 -0500)
commit850b4a23e513c9d133bad008fdf1058d77ff877c
treec315f563e88a2b02eaecb07bbeb538e3eadc10de
parent76f525d94ec42373726dbe18c1c63172c71d26db
Use IndexOf for .* in RegexInterpreter/Compiler (#31930)

* Clean up RegexInterpreter

Almost entirely style.  A few substantive but small changes:
- Store the TextInfo rather than storing the CultureInfo and accessing the TextInfo virtual property on each call.
- Removed unnecessary resx string that should have been an assert
- Coalesced duplicate case blocks

* Use IndexOf for Notoneloop{atomic} in RegexInterpreter/Compiler

This is primarily to improve the performance of .* loops.  We'll now use Span.IndexOf to search for the target character (e.g. \n), rather than the open-coded loop we currently have.

* Address PR feedback
src/libraries/System.Text.RegularExpressions/src/Resources/Strings.resx
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCode.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexInterpreter.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexNode.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParser.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexPrefixAnalyzer.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexWriter.cs