diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h index 18a16a3461c14..bf0e5f284b12e 100644 --- a/lldb/include/lldb/Utility/Stream.h +++ b/lldb/include/lldb/Utility/Stream.h @@ -270,10 +270,8 @@ class Stream { /// optional string following the indentation spaces. /// /// \param[in] s - /// A C string to print following the indentation. If nullptr, just - /// output the indentation characters. - size_t Indent(const char *s = nullptr); - size_t Indent(llvm::StringRef s); + /// A string to print following the indentation. + size_t Indent(llvm::StringRef s = ""); /// Decrement the current indentation level. void IndentLess(unsigned amount = 2); diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp index ca43c013a4264..8d32b56745027 100644 --- a/lldb/source/Utility/Stream.cpp +++ b/lldb/source/Utility/Stream.cpp @@ -126,15 +126,9 @@ size_t Stream::PrintfVarArg(const char *format, va_list args) { // Print and End of Line character to the stream size_t Stream::EOL() { return PutChar('\n'); } -// Indent the current line using the current indentation level and print an -// optional string following the indentation spaces. -size_t Stream::Indent(const char *s) { - return Printf("%*.*s%s", m_indent_level, m_indent_level, "", s ? s : ""); -} - size_t Stream::Indent(llvm::StringRef str) { - return Printf("%*.*s%s", m_indent_level, m_indent_level, "", - str.str().c_str()); + std::string indentation(m_indent_level, ' '); + return PutCString(indentation) + PutCString(str); } // Stream a character "ch" out to this stream. diff --git a/lldb/unittests/Utility/StreamTest.cpp b/lldb/unittests/Utility/StreamTest.cpp index e5cc2fd3ed49c..940d49fdfdb7d 100644 --- a/lldb/unittests/Utility/StreamTest.cpp +++ b/lldb/unittests/Utility/StreamTest.cpp @@ -148,7 +148,8 @@ TEST_F(StreamTest, SetIndentLevel) { TEST_F(StreamTest, Indent) { s.SetIndentLevel(2); - s.Indent(nullptr); + const char *nullptr_cstring = nullptr; + s.Indent(nullptr_cstring); EXPECT_EQ(" ", TakeValue()); s.Indent("");