From 21599876be328ff6b5c6cf09544ade7e337cb48d Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Mon, 19 Aug 2019 07:22:19 +0000 Subject: [PATCH] [lldb][NFC] Address review comments to StringList for-loop support llvm-svn: 369237 --- lldb/include/lldb/Utility/StringList.h | 8 ++++---- lldb/source/Commands/CommandObjectType.cpp | 5 ++--- lldb/source/Utility/StringList.cpp | 1 + lldb/unittests/Utility/StringListTest.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Utility/StringList.h b/lldb/include/lldb/Utility/StringList.h index 1c70d39..6d7474e 100644 --- a/lldb/include/lldb/Utility/StringList.h +++ b/lldb/include/lldb/Utility/StringList.h @@ -23,7 +23,7 @@ class Stream; namespace lldb_private { class StringList { - typedef std::vector StorageType; + typedef std::vector 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 diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index f5d82a2..cbe0e37 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -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, diff --git a/lldb/source/Utility/StringList.cpp b/lldb/source/Utility/StringList.cpp index c242ccaf..f570c32 100644 --- a/lldb/source/Utility/StringList.cpp +++ b/lldb/source/Utility/StringList.cpp @@ -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()); } diff --git a/lldb/unittests/Utility/StringListTest.cpp b/lldb/unittests/Utility/StringListTest.cpp index 264ec92..926f75f 100644 --- a/lldb/unittests/Utility/StringListTest.cpp +++ b/lldb/unittests/Utility/StringListTest.cpp @@ -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"); -- 2.7.4