diff options
Diffstat (limited to 'lib/Support/raw_ostream.cpp')
-rw-r--r-- | lib/Support/raw_ostream.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 917e6be669..94507bd67b 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -289,6 +289,23 @@ raw_ostream &raw_ostream::operator<<(const format_object_base &Fmt) { } } +/// indent - Insert 'NumSpaces' spaces. +raw_ostream &raw_ostream::indent(unsigned NumSpaces) { + const char *Spaces = " "; + + // Usually the indentation is small, handle it with a fastpath. + if (NumSpaces <= 16) + return write(Spaces, NumSpaces); + + while (NumSpaces) { + unsigned NumToWrite = std::min(NumSpaces, 16U); + write(Spaces, NumToWrite); + NumSpaces -= NumToWrite; + } + return *this; +} + + //===----------------------------------------------------------------------===// // Formatted Output //===----------------------------------------------------------------------===// |