summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-20 05:22:52 +0000
committerChris Lattner <sabre@nondot.org>2009-09-20 05:22:52 +0000
commit8d0309daa09937f377d4470e7e7766a549280d45 (patch)
tree7538e9d28d4760b0c809f667ff968e6268617bbd /llvm/lib/Support/CommandLine.cpp
parent64dbb5ca5a18113837cf391a3753610f34b36155 (diff)
downloadbcm5719-llvm-8d0309daa09937f377d4470e7e7766a549280d45.tar.gz
bcm5719-llvm-8d0309daa09937f377d4470e7e7766a549280d45.zip
eliminate the duplicate detection loop, moving it into the loop that populates the Opts vector in the first place.
llvm-svn: 82367
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r--llvm/lib/Support/CommandLine.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 228d60a62e0..681bc1d911e 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -1033,6 +1033,8 @@ public:
// Copy Options into a vector so we can sort them as we like.
std::vector<Option*> Opts;
+ SmallPtrSet<Option*, 128> OptionSet; // Duplicate option detection.
+
for (StringMap<Option*>::iterator I = OptMap.begin(), E = OptMap.end();
I != E; ++I) {
// Ignore really-hidden options.
@@ -1043,20 +1045,11 @@ public:
if (I->second->getOptionHiddenFlag() == Hidden && !ShowHidden)
continue;
- Opts.push_back(I->second);
- }
+ // If we've already seen this option, don't add it to the list again.
+ if (OptionSet.insert(I->second))
+ continue;
- // 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.insert(Opts[i])) // Add new entry to set
- continue;
- // Erase duplicate.
- Opts[i] = Opts.back();
- Opts.pop_back();
- --i;
- }
+ Opts.push_back(I->second);
}
if (ProgramOverview)
OpenPOWER on IntegriCloud