[Lldb-commits] [lldb] 651936e - [lldb][NFC] Remove Stream::Indent(const char *) overload in favor of the StringRef version
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Feb 11 04:30:00 PST 2020
Author: Raphael Isemann
Date: 2020-02-11T13:29:32+01:00
New Revision: 651936e5b62a6a06b1aca1cd976503f5b2991051
URL: https://github.com/llvm/llvm-project/commit/651936e5b62a6a06b1aca1cd976503f5b2991051
DIFF: https://github.com/llvm/llvm-project/commit/651936e5b62a6a06b1aca1cd976503f5b2991051.diff
LOG: [lldb][NFC] Remove Stream::Indent(const char *) overload in favor of the StringRef version
Added:
Modified:
lldb/include/lldb/Utility/Stream.h
lldb/source/Utility/Stream.cpp
lldb/unittests/Utility/StreamTest.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h
index 18a16a3461c1..bf0e5f284b12 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 ca43c013a426..8d32b5674502 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 e5cc2fd3ed49..940d49fdfdb7 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("");
More information about the lldb-commits
mailing list