[cfe-commits] r166218 - /cfe/trunk/lib/Frontend/TextDiagnostic.cpp
Benjamin Kramer
benny.kra at googlemail.com
Thu Oct 18 13:09:54 PDT 2012
Author: d0k
Date: Thu Oct 18 15:09:54 2012
New Revision: 166218
URL: http://llvm.org/viewvc/llvm-project?rev=166218&view=rev
Log:
Emit diagnostics in chunks even when we're trying to print colored template diffs.
char-by-char is really slow on an unbuffered stream.
Modified:
cfe/trunk/lib/Frontend/TextDiagnostic.cpp
Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=166218&r1=166217&r2=166218&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Thu Oct 18 15:09:54 2012
@@ -43,19 +43,22 @@
/// \brief Add highlights to differences in template strings.
static void applyTemplateHighlighting(raw_ostream &OS, StringRef Str,
bool &Normal, bool Bold) {
- for (unsigned i = 0, e = Str.size(); i < e; ++i)
- if (Str[i] != ToggleHighlight) {
- OS << Str[i];
- } else {
- if (Normal)
- OS.changeColor(templateColor, true);
- else {
- OS.resetColor();
- if (Bold)
- OS.changeColor(savedColor, true);
- }
- Normal = !Normal;
+ while (1) {
+ size_t Pos = Str.find(ToggleHighlight);
+ OS << Str.slice(0, Pos);
+ if (Pos == StringRef::npos)
+ break;
+
+ Str = Str.substr(Pos + 1);
+ if (Normal)
+ OS.changeColor(templateColor, true);
+ else {
+ OS.resetColor();
+ if (Bold)
+ OS.changeColor(savedColor, true);
}
+ Normal = !Normal;
+ }
}
/// \brief Number of spaces to indent when word-wrapping.
More information about the cfe-commits
mailing list