mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
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
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
/// ComputeColumn - Examine the current output and figure out which
|
||||
@@ -44,9 +46,17 @@ void formatted_raw_ostream::PadToColumn(unsigned NewCol, unsigned MinPad) {
|
||||
if (NewCol < Column || num < MinPad)
|
||||
num = MinPad;
|
||||
|
||||
// TODO: Write a whole string at a time.
|
||||
while (num-- > 0)
|
||||
write(' ');
|
||||
// Keep a buffer of spaces handy to speed up processing.
|
||||
static char Spaces[MAX_COLUMN_PAD];
|
||||
static bool Initialized = false;
|
||||
if (!Initialized) {
|
||||
std::fill_n(Spaces, MAX_COLUMN_PAD, ' '),
|
||||
Initialized = true;
|
||||
}
|
||||
|
||||
assert(num < MAX_COLUMN_PAD && "Unexpectedly large column padding");
|
||||
|
||||
write(Spaces, num);
|
||||
}
|
||||
|
||||
/// fouts() - This returns a reference to a formatted_raw_ostream for
|
||||
|
||||
Reference in New Issue
Block a user