diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-19 16:25:25 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-19 16:25:25 +0000 |
commit | ecbd0bc478ff3c53a4c2c3cb15098ee24c8218cb (patch) | |
tree | efe9656c3c6b9d7bf7a87d8eb78f63107db7c67a /lib/Support/raw_ostream.cpp | |
parent | dc4bdcdef1c8dd1a28b82deb08df039e5c0ffc5a (diff) |
Speculatively revert r79375, which may be breaking bootstrap, although in a
rather obscure way (the other candidate is r79377).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/raw_ostream.cpp')
-rw-r--r-- | lib/Support/raw_ostream.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 4c3348d830..e7e4ad3f90 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -123,24 +123,19 @@ raw_ostream &raw_ostream::operator<<(long N) { } raw_ostream &raw_ostream::operator<<(unsigned long long N) { - // Handle simple case when value fits in long already. + // Output using 32-bit div/mod when possible. if (N == static_cast<unsigned long>(N)) return this->operator<<(static_cast<unsigned long>(N)); - // Otherwise divide into at two or three 10**9 chunks and write out using - // long div/mod, this is substantially faster on a 32-bit system. - unsigned long Top = 0, Mid = 0, Bot = N % 1000000000; - N /= 1000000000; - if (N > 1000000000) { - Mid = N % 1000000000; - Top = N / 1000000000; - } else - Mid = N; - - if (Top) - this->operator<<(static_cast<unsigned long>(Top)); - this->operator<<(static_cast<unsigned long>(Mid)); - return this->operator<<(static_cast<unsigned long>(Bot)); + 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 &raw_ostream::operator<<(long long N) { |