aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-24 04:13:01 +0000
committerDan Gohman <gohman@apple.com>2009-08-24 04:13:01 +0000
commitf88f52e3b9a692e0f286d0422c892db843cfe41c (patch)
treeaa90f6f5e37f2478d5fddcae8094617f97776c76 /llvm/lib/Support/raw_ostream.cpp
parent72bb4f602c03f847d7b8cafb041a678ea261cc37 (diff)
downloadllvm-f88f52e3b9a692e0f286d0422c892db843cfe41c.zip
llvm-f88f52e3b9a692e0f286d0422c892db843cfe41c.tar.gz
llvm-f88f52e3b9a692e0f286d0422c892db843cfe41c.tar.bz2
raw_ostream::indent is used for PadToColumn which often prints more
than 16 spaces. Make the Spaces array wide enough to handle common cases. llvm-svn: 79890
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 0736a85..64d9205 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/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 <sys/stat.h>
#include <sys/types.h>
@@ -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;
}