Skip to content

Commit 46a32f7

Browse files
committed
Improves regex parsing performance
Adds `RegexOptions.Compiled` to regex definitions in the `TwoPartFormatParser` to improve performance.
1 parent 993eb8b commit 46a32f7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Exceptionless.DateTimeExtensions/FormatParsers/FormatParsers/TwoPartFormatParser.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace Exceptionless.DateTimeExtensions.FormatParsers;
88
[Priority(25)]
99
public class TwoPartFormatParser : IFormatParser
1010
{
11-
private static readonly Regex _beginRegex = new(@"^\s*(?:[\[\{])?\s*");
12-
private static readonly Regex _delimiterRegex = new(@"\G(?:\s*-\s*|\s+TO\s+)", RegexOptions.IgnoreCase);
13-
private static readonly Regex _endRegex = new(@"\G\s*(?:[\]\}])?\s*$");
11+
private static readonly Regex _beginRegex = new(@"^\s*(?:[\[\{])?\s*", RegexOptions.Compiled);
12+
private static readonly Regex _delimiterRegex = new(@"\G(?:\s*-\s*|\s+TO\s+)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
13+
private static readonly Regex _endRegex = new(@"\G\s*(?:[\]\}])?\s*$", RegexOptions.Compiled);
1414

1515
public TwoPartFormatParser()
1616
{

0 commit comments

Comments
 (0)