diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-18 20:09:54 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-18 20:09:54 +0000 |
commit | 4ca3abd3680afec6207d25d0bb80838bf59ecbfe (patch) | |
tree | 47a3976398764b8b66eb1ddcb29080cd3e8e6d3a /lib/Frontend/TextDiagnostic.cpp | |
parent | d052ebf6ca1a9ae3123a8ee22bc37e58ddb61018 (diff) |
Emit diagnostics in chunks even when we're trying to print colored template diffs.
char-by-char is really slow on an unbuffered stream.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/TextDiagnostic.cpp')
-rw-r--r-- | lib/Frontend/TextDiagnostic.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp index a8a5613eaa..e47b5687ff 100644 --- a/lib/Frontend/TextDiagnostic.cpp +++ b/lib/Frontend/TextDiagnostic.cpp @@ -43,19 +43,22 @@ static const enum raw_ostream::Colors savedColor = /// \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. |