diff options
author | Chris Lattner <sabre@nondot.org> | 2009-09-20 05:15:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-09-20 05:15:12 +0000 |
commit | 28610b98784ab62f10e9452a6aebf91e8164b0cb (patch) | |
tree | 95b80beb73fb22acd3faf353cd1f9d84fc6034c1 /llvm/lib/Support/CommandLine.cpp | |
parent | 41f8b0b7a65fed974b66341864ba58625858765a (diff) | |
download | bcm5719-llvm-28610b98784ab62f10e9452a6aebf91e8164b0cb.tar.gz bcm5719-llvm-28610b98784ab62f10e9452a6aebf91e8164b0cb.zip |
don't use count + insert, just do insert + failure. Also, instead of deleting from
the middle of a vector, swap the last element in and pop_back. Also saves 330 bytes :)
llvm-svn: 82365
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index f5ce5a71232..e2da198ea7b 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -1051,14 +1051,17 @@ public: std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), Opts.end()); - // Eliminate duplicate entries in table (from enum flags options, f.e.) + // Eliminate duplicate entries in table (from enum flags options, f.e.). { // Give OptionSet a scope SmallPtrSet<Option*, 32> OptionSet; - for (unsigned i = 0; i != Opts.size(); ++i) - if (OptionSet.count(Opts[i]) == 0) - OptionSet.insert(Opts[i]); // Add new entry to set - else - Opts.erase(Opts.begin()+i--); // Erase duplicate + for (unsigned i = 0; i != Opts.size(); ++i) { + if (OptionSet.insert(Opts[i])) // Add new entry to set + continue; + // Erase duplicate. + Opts[i] = Opts.back(); + Opts.pop_back(); + --i; + } } if (ProgramOverview) |