aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/raw_ostream.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h
index 3de31d6676..96adc465a7 100644
--- a/include/llvm/Support/raw_ostream.h
+++ b/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;
}