[Support] Timer: Use emplace_back() and range-based loops (NFC)
authorVedant Kumar <vsk@apple.com>
Mon, 21 Dec 2015 23:41:38 +0000 (23:41 +0000)
committerVedant Kumar <vsk@apple.com>
Mon, 21 Dec 2015 23:41:38 +0000 (23:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256217 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Timer.cpp

index c3a385f471f9d12953d383648d3049c98e99479c..f8ab214bfbf60af4aa89053368b92c5b27a7e79c 100644 (file)
@@ -272,7 +272,7 @@ void TimerGroup::removeTimer(Timer &T) {
   
   // If the timer was started, move its data to TimersToPrint.
   if (T.Started)
   
   // If the timer was started, move its data to TimersToPrint.
   if (T.Started)
-    TimersToPrint.push_back(std::make_pair(T.Time, T.Name));
+    TimersToPrint.emplace_back(T.Time, T.Name);
 
   T.TG = nullptr;
   
 
   T.TG = nullptr;
   
@@ -306,8 +306,8 @@ void TimerGroup::PrintQueuedTimers(raw_ostream &OS) {
   std::sort(TimersToPrint.begin(), TimersToPrint.end());
   
   TimeRecord Total;
   std::sort(TimersToPrint.begin(), TimersToPrint.end());
   
   TimeRecord Total;
-  for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i)
-    Total += TimersToPrint[i].first;
+  for (auto &RecordNamePair : TimersToPrint)
+    Total += RecordNamePair.first;
   
   // Print out timing header.
   OS << "===" << std::string(73, '-') << "===\n";
   
   // Print out timing header.
   OS << "===" << std::string(73, '-') << "===\n";
@@ -358,7 +358,7 @@ void TimerGroup::print(raw_ostream &OS) {
   // reset them.
   for (Timer *T = FirstTimer; T; T = T->Next) {
     if (!T->Started) continue;
   // reset them.
   for (Timer *T = FirstTimer; T; T = T->Next) {
     if (!T->Started) continue;
-    TimersToPrint.push_back(std::make_pair(T->Time, T->Name));
+    TimersToPrint.emplace_back(T->Time, T->Name);
     
     // Clear out the time.
     T->Started = 0;
     
     // Clear out the time.
     T->Started = 0;