Emit diagnostics in chunks even when we're trying to print colored template diffs.

char-by-char is really slow on an unbuffered stream.

llvm-svn: 166218
This commit is contained in:
Benjamin Kramer 2012-10-18 20:09:54 +00:00
parent 5ea6969422
commit fce09f139c
1 changed files with 15 additions and 12 deletions

View File

@ -43,19 +43,22 @@ static const enum raw_ostream::Colors savedColor =
/// \brief Add highlights to differences in template strings. /// \brief Add highlights to differences in template strings.
static void applyTemplateHighlighting(raw_ostream &OS, StringRef Str, static void applyTemplateHighlighting(raw_ostream &OS, StringRef Str,
bool &Normal, bool Bold) { bool &Normal, bool Bold) {
for (unsigned i = 0, e = Str.size(); i < e; ++i) while (1) {
if (Str[i] != ToggleHighlight) { size_t Pos = Str.find(ToggleHighlight);
OS << Str[i]; OS << Str.slice(0, Pos);
} else { if (Pos == StringRef::npos)
if (Normal) break;
OS.changeColor(templateColor, true);
else { Str = Str.substr(Pos + 1);
OS.resetColor(); if (Normal)
if (Bold) OS.changeColor(templateColor, true);
OS.changeColor(savedColor, true); else {
} OS.resetColor();
Normal = !Normal; if (Bold)
OS.changeColor(savedColor, true);
} }
Normal = !Normal;
}
} }
/// \brief Number of spaces to indent when word-wrapping. /// \brief Number of spaces to indent when word-wrapping.