[llvm-commits] CVS: llvm/include/llvm/Support/CommandLine.h

Chris Lattner sabre at nondot.org
Fri Apr 6 11:36:46 PDT 2007



Changes in directory llvm/include/llvm/Support:

CommandLine.h updated: 1.61 -> 1.62
---
Log message:

Switch some vectors to smallvectors.  This reduces amount of malloc'd
memory that occurs before main starts from 5104 to 4864 bytes with a dummy
example app.


---
Diffs of the changes:  (+8 -6)

 CommandLine.h |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)


Index: llvm/include/llvm/Support/CommandLine.h
diff -u llvm/include/llvm/Support/CommandLine.h:1.61 llvm/include/llvm/Support/CommandLine.h:1.62
--- llvm/include/llvm/Support/CommandLine.h:1.61	Fri Apr  6 13:06:27 2007
+++ llvm/include/llvm/Support/CommandLine.h	Fri Apr  6 13:36:18 2007
@@ -23,6 +23,7 @@
 #include "llvm/Support/type_traits.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/ADT/SmallVector.h"
 #include <string>
 #include <vector>
 #include <utility>
@@ -303,7 +304,7 @@
   // Use a vector instead of a map, because the lists should be short,
   // the overhead is less, and most importantly, it keeps them in the order
   // inserted so we can print our option out nicely.
-  std::vector<std::pair<const char *, std::pair<int, const char *> > > Values;
+  SmallVector<std::pair<const char *, std::pair<int, const char *> >,4> Values;
   void processValues(va_list Vals);
 public:
   ValuesClass(const char *EnumName, DataType Val, const char *Desc,
@@ -424,8 +425,8 @@
 template <class DataType>
 class parser : public generic_parser_base {
 protected:
-  std::vector<std::pair<const char *,
-                        std::pair<DataType, const char *> > > Values;
+  SmallVector<std::pair<const char *,
+                        std::pair<DataType, const char *> >, 8> Values;
 public:
   typedef DataType parser_data_type;
 
@@ -454,7 +455,8 @@
     return O.error(": Cannot find option named '" + ArgVal + "'!");
   }
 
-  // addLiteralOption - Add an entry to the mapping table...
+  /// addLiteralOption - Add an entry to the mapping table.
+  ///
   template <class DT>
   void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) {
     assert(findOption(Name) == Values.size() && "Option already exists!");
@@ -462,8 +464,8 @@
                              std::make_pair(static_cast<DataType>(V),HelpStr)));
   }
 
-  // removeLiteralOption - Remove the specified option.
-  //
+  /// removeLiteralOption - Remove the specified option.
+  ///
   void removeLiteralOption(const char *Name) {
     unsigned N = findOption(Name);
     assert(N != Values.size() && "Option not found!");






More information about the llvm-commits mailing list