diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/Support/raw_ostream.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h index 3de31d66769..96adc465a7b 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -119,7 +119,17 @@ public: } raw_ostream &operator<<(const char *Str) { - write(Str, strlen(Str)); + // Inline fast path, particulary for constant strings where a + // sufficiently smart compiler will simplify strlen. + + unsigned Size = strlen(Str); + + // Make sure we can use the fast path. + if (OutBufCur+Size > OutBufEnd) + return write(Str, Size); + + memcpy(OutBufCur, Str, Size); + OutBufCur += Size; return *this; } |