diff options
author | David Greene <greened@obbligato.org> | 2009-07-28 23:26:34 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2009-07-28 23:26:34 +0000 |
commit | 7aaad71722aeb26f14c8523ee55df91e38837a02 (patch) | |
tree | c3218db2a16aea30b8c6f71bb9d158da978f98d2 /lib/Support/FormattedStream.cpp | |
parent | a87861e4f88a40705e99c92ce3f01e4c365945de (diff) | |
download | external_llvm-7aaad71722aeb26f14c8523ee55df91e38837a02.zip external_llvm-7aaad71722aeb26f14c8523ee55df91e38837a02.tar.gz external_llvm-7aaad71722aeb26f14c8523ee55df91e38837a02.tar.bz2 |
Improve performance of PadToColumn by eliminating flushes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77397 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/FormattedStream.cpp')
-rw-r--r-- | lib/Support/FormattedStream.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Support/FormattedStream.cpp b/lib/Support/FormattedStream.cpp index 1796f9f..1198ebf 100644 --- a/lib/Support/FormattedStream.cpp +++ b/lib/Support/FormattedStream.cpp @@ -19,11 +19,11 @@ using namespace llvm; /// ComputeColumn - Examine the current output and figure out which /// column we end up in after output. /// -void formatted_raw_ostream::ComputeColumn(const char *Ptr, size_t Size) { +void formatted_raw_ostream::ComputeColumn(unsigned &Column) { // Keep track of the current column by scanning the string for // special characters - for (const char *epos = Ptr + Size; Ptr != epos; ++Ptr) { + for (const char *Ptr = begin(); Ptr != end(); ++Ptr) { ++Column; if (*Ptr == '\n' || *Ptr == '\r') Column = 0; @@ -38,8 +38,13 @@ void formatted_raw_ostream::ComputeColumn(const char *Ptr, size_t Size) { /// \param MinPad - The minimum space to give after the most recent /// I/O, even if the current column + minpad > newcol. /// -void formatted_raw_ostream::PadToColumn(unsigned NewCol, unsigned MinPad) { - flush(); +void formatted_raw_ostream::PadToColumn(unsigned NewCol, unsigned MinPad) { + // Start out from the last flush position. + unsigned Column = ColumnFlushed; + + // Now figure out what's in the buffer and add it to the column + // count. + ComputeColumn(Column); // Output spaces until we reach the desired column. unsigned num = NewCol - Column; |