[Lldb-commits] [PATCH] D66345: [lldb][NFC] Allow for-range iterating over StringList

Adrian McCarthy via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 16 15:37:43 PDT 2019


amccarth added inline comments.


================
Comment at: lldb/source/Commands/CommandObjectApropos.cpp:70
+            max_len = std::max(max_len, command.size());
           }
 
----------------
Or

```
const size_t max_len =
    std::max_element(commands_found.begin(), commands_found.end());
```


================
Comment at: lldb/source/Commands/CommandObjectType.cpp:439
+                for (const std::string &type_name : options->m_target_types) {
                   ConstString const_type_name(type_name);
                   if (const_type_name) {
----------------
Constructing the const_type_name isn't necessary anymore.  Just change the if to:

```
if (!type_name.empty())
```



================
Comment at: lldb/source/Utility/StringList.cpp:67
-  for (size_t i = 0; i < len; ++i)
-    m_strings.push_back(strings.GetStringAtIndex(i));
 }
----------------
Optionally add:

```
m_strings.reserve(m_strings.size() + strings.GetSize());
```


================
Comment at: lldb/unittests/Utility/StringListTest.cpp:515
+
+TEST(StringListTest, ForRangeSingle) {
+  StringList s;
----------------
What does "ForRangeSingle" mean here?  The name led me to believe you were going to test a 1-element StringList, but I see three elements.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66345/new/

https://reviews.llvm.org/D66345





More information about the lldb-commits mailing list