[llvm-commits] [llvm] r67053 - in /llvm/trunk: include/llvm/Support/raw_ostream.h lib/Support/raw_ostream.cpp

Daniel Dunbar daniel at zuster.org
Mon Mar 16 15:00:17 PDT 2009


Author: ddunbar
Date: Mon Mar 16 17:00:17 2009
New Revision: 67053

URL: http://llvm.org/viewvc/llvm-project?rev=67053&view=rev
Log:
Add slow path for single character write, and use exclusively for
single characters writes outside of the fast path in raw_ostream.h

Modified:
    llvm/trunk/include/llvm/Support/raw_ostream.h
    llvm/trunk/lib/Support/raw_ostream.cpp

Modified: llvm/trunk/include/llvm/Support/raw_ostream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=67053&r1=67052&r2=67053&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Mon Mar 16 17:00:17 2009
@@ -82,7 +82,7 @@
 
   raw_ostream &operator<<(char C) {
     if (OutBufCur >= OutBufEnd)
-      flush_impl();
+      return write(C);
     *OutBufCur++ = C;
     if (Unbuffered)
       flush_impl();
@@ -91,7 +91,7 @@
 
   raw_ostream &operator<<(unsigned char C) {
     if (OutBufCur >= OutBufEnd)
-      flush_impl();
+      return write(C);
     *OutBufCur++ = C;
     if (Unbuffered)
       flush_impl();
@@ -100,7 +100,7 @@
 
   raw_ostream &operator<<(signed char C) {
     if (OutBufCur >= OutBufEnd)
-      flush_impl();
+      return write(C);
     *OutBufCur++ = C;
     if (Unbuffered)
       flush_impl();
@@ -132,6 +132,7 @@
     return this->operator<<(ftostr(N));
   }
 
+  raw_ostream &write(unsigned char C);
   raw_ostream &write(const char *Ptr, unsigned Size);
 
   // Formatted output, see the format() function in Support/Format.h.

Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=67053&r1=67052&r2=67053&view=diff

==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Mon Mar 16 17:00:17 2009
@@ -63,10 +63,7 @@
 
 raw_ostream &raw_ostream::operator<<(long N) {
   if (N <  0) {
-    if (OutBufCur >= OutBufEnd)
-      flush_impl();
-    *OutBufCur++ = '-';
-    
+    *this << '-';
     N = -N;
   }
   
@@ -91,10 +88,7 @@
 
 raw_ostream &raw_ostream::operator<<(long long N) {
   if (N <  0) {
-    if (OutBufCur >= OutBufEnd)
-      flush_impl();
-    *OutBufCur++ = '-';
-    
+    *this << '-';
     N = -N;
   }
   
@@ -106,6 +100,12 @@
   return *this << format("%p", P);
 }
 
+raw_ostream &raw_ostream::write(unsigned char C) {
+  if (OutBufCur >= OutBufEnd)
+    flush_impl();
+
+  *OutBufCur++ = C;
+}
 
 raw_ostream &raw_ostream::write(const char *Ptr, unsigned Size) {
   if (OutBufCur+Size > OutBufEnd)





More information about the llvm-commits mailing list