[llvm-commits] [llvm] r82372 - /llvm/trunk/lib/Support/CommandLine.cpp
Chris Lattner
sabre at nondot.org
Sat Sep 19 22:53:48 PDT 2009
Author: lattner
Date: Sun Sep 20 00:53:47 2009
New Revision: 82372
URL: http://llvm.org/viewvc/llvm-project?rev=82372&view=rev
Log:
strength reduce further StringRef-> const char*, saving another 620 bytes.
Modified:
llvm/trunk/lib/Support/CommandLine.cpp
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=82372&r1=82371&r2=82372&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Sun Sep 20 00:53:47 2009
@@ -28,7 +28,6 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/config.h"
#include <cerrno>
@@ -1121,6 +1120,11 @@
static void (*OverrideVersionPrinter)() = 0;
+static int TargetArraySortFn(const void *LHS, const void *RHS) {
+ typedef std::pair<const char *, const Target*> pair_ty;
+ return strcmp(((const pair_ty*)LHS)->first, ((const pair_ty*)RHS)->first);
+}
+
namespace {
class VersionPrinter {
public:
@@ -1145,18 +1149,20 @@
<< "\n"
<< " Registered Targets:\n";
- std::vector<std::pair<StringRef, const Target*> > Targets;
+ std::vector<std::pair<const char *, const Target*> > Targets;
size_t Width = 0;
for (TargetRegistry::iterator it = TargetRegistry::begin(),
ie = TargetRegistry::end(); it != ie; ++it) {
Targets.push_back(std::make_pair(it->getName(), &*it));
- Width = std::max(Width, Targets.back().first.size());
+ Width = std::max(Width, strlen(Targets.back().first));
}
- array_pod_sort(Targets.begin(), Targets.end());
+ if (!Targets.empty())
+ qsort(&Targets[0], Targets.size(), sizeof(Targets[0]),
+ TargetArraySortFn);
for (unsigned i = 0, e = Targets.size(); i != e; ++i) {
outs() << " " << Targets[i].first;
- outs().indent(Width - Targets[i].first.size()) << " - "
+ outs().indent(Width - strlen(Targets[i].first)) << " - "
<< Targets[i].second->getShortDescription() << '\n';
}
if (Targets.empty())
More information about the llvm-commits
mailing list