Eliminate a masochistic "algorithm" loop, shrinking CommandLine.o from 71524->70700 bytes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82366 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-09-20 05:18:28 +00:00
parent b40b7e3faf
commit 081bcb0d41

View File

@ -1017,14 +1017,6 @@ class HelpPrinter {
const Option *EmptyArg;
const bool ShowHidden;
// isHidden/isReallyHidden - Predicates to be used to filter down arg lists.
inline static bool isHidden(Option *Opt) {
return Opt->getOptionHiddenFlag() >= Hidden;
}
inline static bool isReallyHidden(Option *Opt) {
return Opt->getOptionHiddenFlag() == ReallyHidden;
}
public:
explicit HelpPrinter(bool showHidden) : ShowHidden(showHidden) {
EmptyArg = 0;
@ -1043,14 +1035,17 @@ public:
std::vector<Option*> Opts;
for (StringMap<Option*>::iterator I = OptMap.begin(), E = OptMap.end();
I != E; ++I) {
// Ignore really-hidden options.
if (I->second->getOptionHiddenFlag() == ReallyHidden)
continue;
// Unless showhidden is set, ignore hidden flags.
if (I->second->getOptionHiddenFlag() == Hidden && !ShowHidden)
continue;
Opts.push_back(I->second);
}
// Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden
Opts.erase(std::remove_if(Opts.begin(), Opts.end(),
std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)),
Opts.end());
// Eliminate duplicate entries in table (from enum flags options, f.e.).
{ // Give OptionSet a scope
SmallPtrSet<Option*, 32> OptionSet;