[llvm-commits] [llvm] r82367 - /llvm/trunk/lib/Support/CommandLine.cpp
Chris Lattner
sabre at nondot.org
Sat Sep 19 22:22:53 PDT 2009
Author: lattner
Date: Sun Sep 20 00:22:52 2009
New Revision: 82367
URL: http://llvm.org/viewvc/llvm-project?rev=82367&view=rev
Log:
eliminate the duplicate detection loop, moving it into the loop that populates the Opts vector in the first place.
Modified:
llvm/trunk/lib/Support/CommandLine.cpp
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=82367&r1=82366&r2=82367&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Sun Sep 20 00:22:52 2009
@@ -1033,6 +1033,8 @@
// 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 @@
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)
More information about the llvm-commits
mailing list