[lldb][NFC] Address review comments to StringList for-loop support
authorRaphael Isemann <teemperor@gmail.com>
Mon, 19 Aug 2019 07:22:19 +0000 (07:22 +0000)
committerRaphael Isemann <teemperor@gmail.com>
Mon, 19 Aug 2019 07:22:19 +0000 (07:22 +0000)
llvm-svn: 369237

lldb/include/lldb/Utility/StringList.h
lldb/source/Commands/CommandObjectType.cpp
lldb/source/Utility/StringList.cpp
lldb/unittests/Utility/StringListTest.cpp

index 1c70d39..6d7474e 100644 (file)
@@ -23,7 +23,7 @@ class Stream;
 namespace lldb_private {
 
 class StringList {
-  typedef std::vector<std::string> StorageType;
+  typedef std::vector<std::string> collection;
 
 public:
   StringList();
@@ -54,8 +54,8 @@ public:
 
   size_t GetMaxStringLength() const;
 
-  typedef StorageType::iterator iterator;
-  typedef StorageType::const_iterator const_iterator;
+  typedef collection::iterator iterator;
+  typedef collection::const_iterator const_iterator;
 
   iterator begin() { return m_strings.begin(); }
   iterator end() { return m_strings.end(); }
@@ -135,7 +135,7 @@ public:
   }
 
 private:
-  StorageType m_strings;
+  collection m_strings;
 };
 
 } // namespace lldb_private
index f5d82a2..cbe0e37 100644 (file)
@@ -436,10 +436,9 @@ protected:
                 Status error;
 
                 for (const std::string &type_name : options->m_target_types) {
-                  ConstString const_type_name(type_name);
-                  if (const_type_name) {
+                  if (!type_name.empty()) {
                     if (!CommandObjectTypeSynthAdd::AddSynth(
-                            const_type_name, synth_provider,
+                            ConstString(type_name), synth_provider,
                             options->m_regex
                                 ? CommandObjectTypeSynthAdd::eRegexSynth
                                 : CommandObjectTypeSynthAdd::eRegularSynth,
index c242cca..f570c32 100644 (file)
@@ -61,6 +61,7 @@ void StringList::AppendList(const char **strv, int strc) {
 }
 
 void StringList::AppendList(StringList strings) {
+  m_strings.reserve(m_strings.size() + strings.GetSize());
   m_strings.insert(m_strings.end(), strings.begin(), strings.end());
 }
 
index 264ec92..926f75f 100644 (file)
@@ -512,7 +512,7 @@ TEST(StringListTest, ForRangeEmpty) {
     FAIL() << "Shouldn't have hit an element in for range" << e;
 }
 
-TEST(StringListTest, ForRangeSingle) {
+TEST(StringListTest, ForRange) {
   StringList s;
   s.AppendString("a");
   s.AppendString("b");