summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Statistic.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-10-16 16:30:34 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-10-16 16:30:34 +0000
commitcc863b2bb6bb018416a65b2f9666ca9dd07dcae5 (patch)
treee2838a4c105b98d41a5e9822d05095aa84ca25e8 /llvm/lib/Support/Statistic.cpp
parentcb6b02a0866b568dd83c74daddf570bade449191 (diff)
downloadbcm5719-llvm-cc863b2bb6bb018416a65b2f9666ca9dd07dcae5.tar.gz
bcm5719-llvm-cc863b2bb6bb018416a65b2f9666ca9dd07dcae5.zip
Let printf do the formatting instead aligning strings ourselves.
While at it, merge some format strings. llvm-svn: 142140
Diffstat (limited to 'llvm/lib/Support/Statistic.cpp')
-rw-r--r--llvm/lib/Support/Statistic.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/Support/Statistic.cpp b/llvm/lib/Support/Statistic.cpp
index 1e733d92e61..04a44a0f711 100644
--- a/llvm/lib/Support/Statistic.cpp
+++ b/llvm/lib/Support/Statistic.cpp
@@ -24,6 +24,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/Format.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Mutex.h"
@@ -126,13 +127,11 @@ void llvm::PrintStatistics(raw_ostream &OS) {
<< "===" << std::string(73, '-') << "===\n\n";
// Print all of the statistics.
- for (size_t i = 0, e = Stats.Stats.size(); i != e; ++i) {
- std::string CountStr = utostr(Stats.Stats[i]->getValue());
- OS << std::string(MaxValLen-CountStr.size(), ' ')
- << CountStr << " " << Stats.Stats[i]->getName()
- << std::string(MaxNameLen-std::strlen(Stats.Stats[i]->getName()), ' ')
- << " - " << Stats.Stats[i]->getDesc() << "\n";
- }
+ for (size_t i = 0, e = Stats.Stats.size(); i != e; ++i)
+ OS << format("%*u %-*s - %s\n",
+ MaxValLen, Stats.Stats[i]->getValue(),
+ MaxNameLen, Stats.Stats[i]->getName(),
+ Stats.Stats[i]->getDesc());
OS << '\n'; // Flush the output stream.
OS.flush();
OpenPOWER on IntegriCloud