[llvm] 6427f4c - [NFC] Use an llvm::DenseMap instead of std::map in CategorizedHelpPrinter::printOptions

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 12:51:28 PST 2022


Author: serge-sans-paille
Date: 2022-01-25T21:51:13+01:00
New Revision: 6427f4c52c31cc36004b14825e6598cd4a43f385

URL: https://github.com/llvm/llvm-project/commit/6427f4c52c31cc36004b14825e6598cd4a43f385
DIFF: https://github.com/llvm/llvm-project/commit/6427f4c52c31cc36004b14825e6598cd4a43f385.diff

LOG: [NFC] Use an llvm::DenseMap instead of std::map in CategorizedHelpPrinter::printOptions

Added: 
    

Modified: 
    llvm/lib/Support/CommandLine.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index ed4f01f176c2..e517ceb05d9b 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -45,7 +45,6 @@
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdlib>
-#include <map>
 #include <string>
 using namespace llvm;
 using namespace cl;
@@ -2339,7 +2338,7 @@ class CategorizedHelpPrinter : public HelpPrinter {
 protected:
   void printOptions(StrOptionPairVector &Opts, size_t MaxArgLen) override {
     std::vector<OptionCategory *> SortedCategories;
-    std::map<OptionCategory *, std::vector<Option *>> CategorizedOptions;
+    DenseMap<OptionCategory *, std::vector<Option *>> CategorizedOptions;
 
     // Collect registered option categories into vector in preparation for
     // sorting.
@@ -2351,10 +2350,6 @@ class CategorizedHelpPrinter : public HelpPrinter {
     array_pod_sort(SortedCategories.begin(), SortedCategories.end(),
                    OptionCategoryCompare);
 
-    // Create map to empty vectors.
-    for (OptionCategory *Category : SortedCategories)
-      CategorizedOptions[Category] = std::vector<Option *>();
-
     // Walk through pre-sorted options and assign into categories.
     // Because the options are already alphabetically sorted the
     // options within categories will also be alphabetically sorted.


        


More information about the llvm-commits mailing list