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 | b40b7e3fafe9b6ef68a5b100e2a6601adcb67b8b (patch) | |
tree | a7632a866b29be8154f9deb2cae5763d9eda0da7 /lib/Support/CommandLine.cpp | |
parent | 67aead68beae1fca4c53e92a1682364ba8cb497d (diff) |
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 :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82365 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/CommandLine.cpp')
-rw-r--r-- | lib/Support/CommandLine.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index f5ce5a7123..e2da198ea7 100644 --- a/lib/Support/CommandLine.cpp +++ b/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) |