Skip to content

Commit

Permalink
#608 Improved performance for classes with many lines
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpalme committed Jun 7, 2023
1 parent a46b477 commit 0aeb2d8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ For further details take a look at LICENSE.txt.

CHANGELOG

5.1.22.0

* Fix: #608 Improved performance for classes with many lines

5.1.21.0

* Fix: #606 Improved Cobertura output (complexity metric)
Expand Down
17 changes: 15 additions & 2 deletions src/ReportGenerator.Core/Parser/Analysis/CodeFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ public class CodeFile
/// </summary>
private IFileReader additionalFileReader;

/// <summary>
/// The number of covered lines.
/// </summary>
private int coveredLines;

/// <summary>
/// The number of coverable lines.
/// </summary>
private int coverableLines;

/// <summary>
/// Initializes a new instance of the <see cref="CodeFile" /> class.
/// </summary>
Expand Down Expand Up @@ -126,6 +136,9 @@ internal CodeFile(string path, int[] lineCoverage, LineVisitStatus[] lineVisitSt
this.lineVisitStatus = lineVisitStatus;
this.branches = branches;
this.additionalFileReader = additionalFileReader;

this.coveredLines = this.lineCoverage.Count(l => l > 0);
this.coverableLines = this.lineCoverage.Count(l => l >= 0);
}

/// <summary>
Expand Down Expand Up @@ -160,13 +173,13 @@ internal CodeFile(string path, int[] lineCoverage, LineVisitStatus[] lineVisitSt
/// Gets the number of covered lines.
/// </summary>
/// <value>The number of covered lines.</value>
public int CoveredLines => this.lineCoverage.Count(l => l > 0);
public int CoveredLines => this.coveredLines;

/// <summary>
/// Gets the number of coverable lines.
/// </summary>
/// <value>The number of coverable lines.</value>
public int CoverableLines => this.lineCoverage.Count(l => l >= 0);
public int CoverableLines => this.coverableLines;

/// <summary>
/// Gets the number of total lines.
Expand Down

0 comments on commit 0aeb2d8

Please sign in to comment.