Skip to content

Commit fe38ad3

Browse files
LeeCampbellclaude
andcommitted
fix: use non-greedy tag regex for .NET 10 compatibility
The TaggedLogLineMatcher regex used `.+` (greedy match) in the optional tag group, which relied on backtracking to correctly parse tags. .NET 10 changed regex engine backtracking behaviour, causing the optional group to be skipped entirely instead of backtracking to find the tag value. Replace `Tag=.+` with `Tag=[^,]+` to match only non-comma characters, avoiding the need for backtracking across comma boundaries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3a40a77 commit fe38ad3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

HdrHistogram/HistogramLogReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed class HistogramLogReader : IDisposable, IHistogramLogV1Reader
1818
private static readonly Regex BaseTimeMatcher = new Regex(@"#\[BaseTime: (?<seconds>\d*\.\d{1,3}) ", RegexOptions.Compiled);
1919
//Content lines - format = startTimestamp, intervalLength, maxTime, histogramPayload
2020
private static readonly Regex UntaggedLogLineMatcher = new Regex(@"(?<startTime>\d*\.\d*),(?<interval>\d*\.\d*),(?<max>\d*\.\d*),(?<payload>.*)", RegexOptions.Compiled);
21-
private static readonly Regex TaggedLogLineMatcher = new Regex(@"((?<tag>Tag=.+),)?(?<startTime>\d*\.\d*),(?<interval>\d*\.\d*),(?<max>\d*\.\d*),(?<payload>.*)", RegexOptions.Compiled);
21+
private static readonly Regex TaggedLogLineMatcher = new Regex(@"((?<tag>Tag=[^,]+),)?(?<startTime>\d*\.\d*),(?<interval>\d*\.\d*),(?<max>\d*\.\d*),(?<payload>.*)", RegexOptions.Compiled);
2222
private readonly TextReader _log;
2323
private double _startTimeInSeconds;
2424

0 commit comments

Comments
 (0)