From 61ee100b97adda5dcf1c02df030e5776bb374a5a Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 24 Aug 2009 04:13:01 +0000 Subject: raw_ostream::indent is used for PadToColumn which often prints more than 16 spaces. Make the Spaces array wide enough to handle common cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79890 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/raw_ostream.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 0736a85..64d9205 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -19,6 +19,7 @@ #include "llvm/Config/config.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include #include @@ -298,14 +299,16 @@ raw_ostream &raw_ostream::operator<<(const format_object_base &Fmt) { /// indent - Insert 'NumSpaces' spaces. raw_ostream &raw_ostream::indent(unsigned NumSpaces) { - const char *Spaces = " "; + static const char Spaces[] = " " + " " + " "; // Usually the indentation is small, handle it with a fastpath. - if (NumSpaces <= 16) + if (NumSpaces <= array_lengthof(Spaces)) return write(Spaces, NumSpaces); while (NumSpaces) { - unsigned NumToWrite = std::min(NumSpaces, 16U); + unsigned NumToWrite = std::min(NumSpaces, (unsigned)array_lengthof(Spaces)); write(Spaces, NumToWrite); NumSpaces -= NumToWrite; } -- cgit v1.1