diff options
| author | Fangrui Song <i@maskray.me> | 2024-01-27 16:00:37 -0800 |
|---|---|---|
| committer | Fangrui Song <i@maskray.me> | 2024-01-27 16:00:37 -0800 |
| commit | 927919ac34a2085a7a25814fea492ac462b0d4ac (patch) | |
| tree | 2dbe61043881f5a74d9024aa06eb2173f9d970ac /llvm/tools/llvm-cov/CodeCoverage.cpp | |
| parent | 53fea6fd6f228eb1dbd282b8d076af545dcd8228 (diff) | |
| download | llvm-927919ac34a2085a7a25814fea492ac462b0d4ac.zip llvm-927919ac34a2085a7a25814fea492ac462b0d4ac.tar.gz llvm-927919ac34a2085a7a25814fea492ac462b0d4ac.tar.bz2 | |
[llvm-cov] Simplify branch/MCDC subviews. NFC
Remove unneeded empty check and reundant copies. NFC
Diffstat (limited to 'llvm/tools/llvm-cov/CodeCoverage.cpp')
| -rw-r--r-- | llvm/tools/llvm-cov/CodeCoverage.cpp | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index 6405bb1..049e89d 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -343,17 +343,14 @@ void CodeCoverageTool::attachBranchSubViews(SourceCoverageView &View, // Group branches that have the same line number into the same subview. while (NextBranch != EndBranch) { - std::vector<CountedRegion> ViewBranches; + SmallVector<CountedRegion, 0> ViewBranches; unsigned CurrentLine = NextBranch->LineStart; - while (NextBranch != EndBranch && CurrentLine == NextBranch->LineStart) ViewBranches.push_back(*NextBranch++); - if (!ViewBranches.empty()) { - auto SubView = SourceCoverageView::create(SourceName, File, ViewOpts, - std::move(CoverageInfo)); - View.addBranch(CurrentLine, ViewBranches, std::move(SubView)); - } + View.addBranch(CurrentLine, std::move(ViewBranches), + SourceCoverageView::create(SourceName, File, ViewOpts, + std::move(CoverageInfo))); } } @@ -371,20 +368,15 @@ void CodeCoverageTool::attachMCDCSubViews(SourceCoverageView &View, // Group and process MCDC records that have the same line number into the // same subview. while (NextRecord != EndRecord) { - std::vector<MCDCRecord> ViewMCDCRecords; + SmallVector<MCDCRecord, 0> ViewMCDCRecords; unsigned CurrentLine = NextRecord->getDecisionRegion().LineEnd; - while (NextRecord != EndRecord && - CurrentLine == NextRecord->getDecisionRegion().LineEnd) { + CurrentLine == NextRecord->getDecisionRegion().LineEnd) ViewMCDCRecords.push_back(*NextRecord++); - } - - if (ViewMCDCRecords.empty()) - continue; - auto SubView = SourceCoverageView::create(SourceName, File, ViewOpts, - std::move(CoverageInfo)); - View.addMCDCRecord(CurrentLine, ViewMCDCRecords, std::move(SubView)); + View.addMCDCRecord(CurrentLine, std::move(ViewMCDCRecords), + SourceCoverageView::create(SourceName, File, ViewOpts, + std::move(CoverageInfo))); } } |
