Skip to content

Commit 5f735e9

Browse files
author
Cédric Belin
committed
Code optimization
1 parent 803d768 commit 5f735e9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Report.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ namespace Belin.Lcov;
88
/// </summary>
99
/// <param name="testName">The test name.</param>
1010
/// <param name="sourceFiles">The source file list.</param>
11-
public class Report(string testName, IEnumerable<SourceFile>? sourceFiles = null) {
11+
public partial class Report(string testName, IEnumerable<SourceFile>? sourceFiles = null) {
12+
13+
/// <summary>
14+
/// Gets the regular expression used to split the lines.
15+
/// </summary>
16+
/// <returns>The regular expression used to split the lines.</returns>
17+
[GeneratedRegex(@"\r?\n")]
18+
private static partial Regex NewLinePattern();
1219

1320
/// <summary>
1421
/// The source file list.
@@ -31,7 +38,7 @@ public static Report Parse(string coverage) {
3138
var report = new Report(string.Empty);
3239
var sourceFile = new SourceFile(path: string.Empty);
3340

34-
foreach (var line in Regex.Split(coverage, @"\r?\n")) {
41+
foreach (var line in NewLinePattern().Split(coverage)) {
3542
offset++;
3643
if (string.IsNullOrWhiteSpace(line)) continue;
3744

0 commit comments

Comments
 (0)