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 | 5f6511c3d553c3d51b1116948c07ea5982385f74 (patch) | |
| tree | 8b0dbe708aee3ad738257f4878b92b77859ac5c9 /llvm/lib/Support | |
| parent | 0c96daabadeb9bd580a6ec7639dc607925a5c904 (diff) | |
| download | bcm5719-llvm-5f6511c3d553c3d51b1116948c07ea5982385f74.tar.gz bcm5719-llvm-5f6511c3d553c3d51b1116948c07ea5982385f74.zip  | |
Improve performance of PadToColumn by eliminating flushes.
llvm-svn: 77397
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/FormattedStream.cpp | 13 | 
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Support/FormattedStream.cpp b/llvm/lib/Support/FormattedStream.cpp index 1796f9f9568..1198ebf08e5 100644 --- a/llvm/lib/Support/FormattedStream.cpp +++ b/llvm/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;  | 

