[llvm] r196194 - llvm-cov: Cleaned up print() function slightly.

Yuchen Wu yuchenericwu at hotmail.com
Mon Dec 2 17:35:32 PST 2013


Author: ywu
Date: Mon Dec  2 19:35:31 2013
New Revision: 196194

URL: http://llvm.org/viewvc/llvm-project?rev=196194&view=rev
Log:
llvm-cov: Cleaned up print() function slightly.

Changed while to for loop. Removed unnecessary if statement.

Modified:
    llvm/trunk/lib/IR/GCOV.cpp

Modified: llvm/trunk/lib/IR/GCOV.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/GCOV.cpp?rev=196194&r1=196193&r2=196194&view=diff
==============================================================================
--- llvm/trunk/lib/IR/GCOV.cpp (original)
+++ llvm/trunk/lib/IR/GCOV.cpp Mon Dec  2 19:35:31 2013
@@ -340,11 +340,12 @@ void FileInfo::print(StringRef gcnoFile,
     OS << "        -:    0:Runs:" << RunCount << "\n";
     OS << "        -:    0:Programs:" << ProgramCount << "\n";
 
-    const LineData &L = I->second;
-    uint32_t i = 0;
-    while (!AllLines.empty()) {
-      LineData::const_iterator BlocksIt = L.find(i);
-      if (BlocksIt != L.end()) {
+    const LineData &Line = I->second;
+    for (uint32_t i = 0; !AllLines.empty(); ++i) {
+      LineData::const_iterator BlocksIt = Line.find(i);
+
+      // Add up the block counts to form line counts.
+      if (BlocksIt != Line.end()) {
         const BlockVector &Blocks = BlocksIt->second;
         uint64_t LineCount = 0;
         for (BlockVector::const_iterator I = Blocks.begin(), E = Blocks.end();
@@ -359,11 +360,8 @@ void FileInfo::print(StringRef gcnoFile,
         OS << "        -:";
       }
       std::pair<StringRef, StringRef> P = AllLines.split('\n');
-      if (AllLines != P.first)
-        OS << format("%5u:", i+1) << P.first;
-      OS << "\n";
+      OS << format("%5u:", i+1) << P.first << "\n";
       AllLines = P.second;
-      ++i;
     }
   }
 }





More information about the llvm-commits mailing list