diff --git a/lldb/include/lldb/Core/StringList.h b/lldb/include/lldb/Core/StringList.h index ec482f696b69..1a20f2382e18 100644 --- a/lldb/include/lldb/Core/StringList.h +++ b/lldb/include/lldb/Core/StringList.h @@ -51,8 +51,8 @@ public: const char * GetStringAtIndex (size_t idx) const; - const char * - Join (const char *seperator); + void + Join (const char *separator, Stream &strm); void Clear (); diff --git a/lldb/source/Core/StringList.cpp b/lldb/source/Core/StringList.cpp index 88dd2edb3f83..c4356e7eccc9 100644 --- a/lldb/source/Core/StringList.cpp +++ b/lldb/source/Core/StringList.cpp @@ -95,23 +95,20 @@ StringList::GetStringAtIndex (size_t idx) const return NULL; } -const char * -StringList::Join (const char *separator) +void +StringList::Join (const char *separator, Stream &strm) { uint32_t size = GetSize(); + if (size == 0) - return ""; - if (size == 1) - return GetStringAtIndex(0); - - std::string buf; + return; + for (uint32_t i = 0; i < size; ++i) { if (i > 0) - buf.append(separator); - buf.append(GetStringAtIndex(i)); + strm.PutCString(separator); + strm.PutCString(GetStringAtIndex(i)); } - return buf.c_str();; } void diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index c86bb5e9f7ee..af9aa39e7ed2 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -849,12 +849,15 @@ CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType static const char *arch_helper() { - StringList archs; - ArchSpec::AutoComplete(NULL, archs); - StreamString ss; - ss.Printf("These are the supported architecture names:\n"); - ss.Printf("%s\n", archs.Join("\n")); - return ss.GetData(); + static StreamString g_archs_help; + if (g_archs_help.GetData() == NULL) + { + StringList archs; + ArchSpec::AutoComplete(NULL, archs); + g_archs_help.Printf("These are the supported architecture names:\n"); + archs.Join("%s\n", g_archs_help); + } + return g_archs_help.GetData(); } CommandObject::ArgumentTableEntry