From aee36f94396f1b7eb301a1ff01230fa7fa33cd2f Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Mon, 15 Sep 2014 03:41:01 +0000 Subject: llvm-cov: Simplify CounterMappingRegion, pushing logic to its user A single function in SourceCoverageDataManager was the only user of some of the comparisons in CounterMappingRegion, and at this point we know that only one file is relevant. This lets us use slightly simpler logic directly in the client. llvm-svn: 217745 --- llvm/tools/llvm-cov/SourceCoverageDataManager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'llvm/tools/llvm-cov/SourceCoverageDataManager.cpp') diff --git a/llvm/tools/llvm-cov/SourceCoverageDataManager.cpp b/llvm/tools/llvm-cov/SourceCoverageDataManager.cpp index f64162822ab..6f7c8e5d985 100644 --- a/llvm/tools/llvm-cov/SourceCoverageDataManager.cpp +++ b/llvm/tools/llvm-cov/SourceCoverageDataManager.cpp @@ -26,13 +26,16 @@ ArrayRef SourceCoverageDataManager::getSourceRegions() { if (Uniqued || Regions.size() <= 1) return Regions; - // Sort. - std::sort(Regions.begin(), Regions.end()); + // Sort the regions given that they're all in the same file at this point. + std::sort(Regions.begin(), Regions.end(), + [](const CountedRegion &LHS, const CountedRegion &RHS) { + return LHS.startLoc() < RHS.startLoc(); + }); // Merge duplicate source ranges and sum their execution counts. auto Prev = Regions.begin(); for (auto I = Prev + 1, E = Regions.end(); I != E; ++I) { - if (I->coversSameSource(*Prev)) { + if (I->startLoc() == Prev->startLoc() && I->endLoc() == Prev->endLoc()) { Prev->ExecutionCount += I->ExecutionCount; continue; } -- cgit v1.2.3