llvm.org GIT mirror llvm / ed0e2ad
Write space padding as one string to speed up comment printing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76910 91177308-0d34-0410-b5e6-96231b3b80d8 David Greene 11 years ago
2 changed file(s) with 21 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
2626 /// DELETE_STREAM - Tell the destructor to delete the held stream.
2727 ///
2828 const static bool DELETE_STREAM = true;
29
2930 /// PRESERVE_STREAM - Tell the destructor to not delete the held
3031 /// stream.
3132 ///
3233 const static bool PRESERVE_STREAM = false;
33
34
35 /// MAX_COLUMN_PAD - This is the maximum column padding we ever
36 /// expect to see.
37 ///
38 const static unsigned MAX_COLUMN_PAD = 100;
39
3440 private:
3541 /// TheStream - The real stream we output to. We set it to be
3642 /// unbuffered, since we're already doing our own buffering.
3743 ///
3844 raw_ostream *TheStream;
45
3946 /// DeleteStream - Do we need to delete TheStream in the
4047 /// destructor?
4148 ///
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Support/FormattedStream.h"
14 #include
15
1416 using namespace llvm;
1517
1618 /// ComputeColumn - Examine the current output and figure out which
4345 if (NewCol < Column || num < MinPad)
4446 num = MinPad;
4547
46 // TODO: Write a whole string at a time.
47 while (num-- > 0)
48 write(' ');
48 // Keep a buffer of spaces handy to speed up processing.
49 static char Spaces[MAX_COLUMN_PAD];
50 static bool Initialized = false;
51 if (!Initialized) {
52 std::fill_n(Spaces, MAX_COLUMN_PAD, ' '),
53 Initialized = true;
54 }
55
56 assert(num < MAX_COLUMN_PAD && "Unexpectedly large column padding");
57
58 write(Spaces, num);
4959 }
5060
5161 /// fouts() - This returns a reference to a formatted_raw_ostream for