mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
Make raw_ostream::operator<<(const void *) fast; it doesn't matter but
it is easy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67054 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -96,8 +96,24 @@ raw_ostream &raw_ostream::operator<<(long long N) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
raw_ostream &raw_ostream::operator<<(const void *P) {
|
raw_ostream &raw_ostream::operator<<(const void *P) {
|
||||||
// FIXME: This could be much faster if it matters.
|
uintptr_t N = (uintptr_t) P;
|
||||||
return *this << format("%p", P);
|
*this << '0' << 'x';
|
||||||
|
|
||||||
|
// Zero is a special case.
|
||||||
|
if (N == 0)
|
||||||
|
return *this << '0';
|
||||||
|
|
||||||
|
char NumberBuffer[20];
|
||||||
|
char *EndPtr = NumberBuffer+sizeof(NumberBuffer);
|
||||||
|
char *CurPtr = EndPtr;
|
||||||
|
|
||||||
|
while (N) {
|
||||||
|
unsigned x = N % 16;
|
||||||
|
*--CurPtr = (x < 10 ? '0' + x : 'a' + x - 10);
|
||||||
|
N /= 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
return write(CurPtr, EndPtr-CurPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
raw_ostream &raw_ostream::write(unsigned char C) {
|
raw_ostream &raw_ostream::write(unsigned char C) {
|
||||||
@@ -105,6 +121,7 @@ raw_ostream &raw_ostream::write(unsigned char C) {
|
|||||||
flush_impl();
|
flush_impl();
|
||||||
|
|
||||||
*OutBufCur++ = C;
|
*OutBufCur++ = C;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
raw_ostream &raw_ostream::write(const char *Ptr, unsigned Size) {
|
raw_ostream &raw_ostream::write(const char *Ptr, unsigned Size) {
|
||||||
|
Reference in New Issue
Block a user