summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-20 05:15:12 +0000
committerChris Lattner <sabre@nondot.org>2009-09-20 05:15:12 +0000
commit28610b98784ab62f10e9452a6aebf91e8164b0cb (patch)
tree95b80beb73fb22acd3faf353cd1f9d84fc6034c1 /llvm/lib/Support/CommandLine.cpp
parent41f8b0b7a65fed974b66341864ba58625858765a (diff)
downloadbcm5719-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.cpp15
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)
OpenPOWER on IntegriCloud