summaryrefslogtreecommitdiff
path: root/include/llvm/Support/raw_ostream.h
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-08-21 20:58:52 +0000
committerOwen Anderson <resistor@mac.com>2008-08-21 20:58:52 +0000
commit66b17ba0d263442b8b4e82aaa08acc0df85e1787 (patch)
tree0b96f536365620ed3c286e63121522a2f10934ac /include/llvm/Support/raw_ostream.h
parentdce51c372a9b22aaaca4d8258aa63a336c40e5fd (diff)
downloadllvm-66b17ba0d263442b8b4e82aaa08acc0df85e1787.tar.gz
llvm-66b17ba0d263442b8b4e82aaa08acc0df85e1787.tar.bz2
llvm-66b17ba0d263442b8b4e82aaa08acc0df85e1787.tar.xz
Move non-trivial methods out of line to avoid code-size bloat.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55138 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/raw_ostream.h')
-rw-r--r--include/llvm/Support/raw_ostream.h92
1 files changed, 5 insertions, 87 deletions
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h
index 6ea5930d64..2210de1da1 100644
--- a/include/llvm/Support/raw_ostream.h
+++ b/include/llvm/Support/raw_ostream.h
@@ -77,61 +77,13 @@ public:
return write(Str.data(), Str.length());
}
- raw_ostream &operator<<(unsigned long N) {
- // Zero is a special case.
- if (N == 0)
- return *this << '0';
-
- char NumberBuffer[20];
- char *EndPtr = NumberBuffer+sizeof(NumberBuffer);
- char *CurPtr = EndPtr;
-
- while (N) {
- *--CurPtr = '0' + char(N % 10);
- N /= 10;
- }
- return write(CurPtr, EndPtr-CurPtr);
- }
+ raw_ostream &operator<<(unsigned long N);
- raw_ostream &operator<<(long N) {
- if (N < 0) {
- if (OutBufCur >= OutBufEnd)
- flush_impl();
- *OutBufCur++ = '-';
-
- N = -N;
- }
-
- return this->operator<<(static_cast<unsigned long>(N));
- }
+ raw_ostream &operator<<(long N);
- raw_ostream &operator<<(unsigned long long N) {
- // Zero is a special case.
- if (N == 0)
- return *this << '0';
-
- char NumberBuffer[20];
- char *EndPtr = NumberBuffer+sizeof(NumberBuffer);
- char *CurPtr = EndPtr;
-
- while (N) {
- *--CurPtr = '0' + char(N % 10);
- N /= 10;
- }
- return write(CurPtr, EndPtr-CurPtr);
- }
+ raw_ostream &operator<<(unsigned long long N);
- raw_ostream &operator<<(long long N) {
- if (N < 0) {
- if (OutBufCur >= OutBufEnd)
- flush_impl();
- *OutBufCur++ = '-';
-
- N = -N;
- }
-
- return this->operator<<(static_cast<unsigned long long>(N));
- }
+ raw_ostream &operator<<(long long N);
raw_ostream &operator<<(unsigned int N) {
return this->operator<<(static_cast<unsigned long>(N));
@@ -146,41 +98,7 @@ public:
}
- raw_ostream &write(const char *Ptr, unsigned Size) {
- if (OutBufCur+Size > OutBufEnd)
- flush_impl();
-
- // Handle short strings specially, memcpy isn't very good at very short
- // strings.
- switch (Size) {
- case 4: OutBufCur[3] = Ptr[3]; // FALL THROUGH
- case 3: OutBufCur[2] = Ptr[2]; // FALL THROUGH
- case 2: OutBufCur[1] = Ptr[1]; // FALL THROUGH
- case 1: OutBufCur[0] = Ptr[0]; // FALL THROUGH
- case 0: break;
- default:
- // Normally the string to emit is shorter than the buffer.
- if (Size <= unsigned(OutBufEnd-OutBufStart)) {
- memcpy(OutBufCur, Ptr, Size);
- break;
- }
-
- // If emitting a string larger than our buffer, emit in chunks. In this
- // case we know that we just flushed the buffer.
- while (Size) {
- unsigned NumToEmit = OutBufEnd-OutBufStart;
- if (Size < NumToEmit) NumToEmit = Size;
- assert(OutBufCur == OutBufStart);
- memcpy(OutBufStart, Ptr, NumToEmit);
- Ptr += NumToEmit;
- OutBufCur = OutBufStart + NumToEmit;
- flush_impl();
- }
- break;
- }
- OutBufCur += Size;
- return *this;
- }
+ raw_ostream &write(const char *Ptr, unsigned Size);
//===--------------------------------------------------------------------===//
// Subclass Interface