Remove manual byte counting from Highlighter code.
Summary:
This removes the manual byte counting mechanism from the syntax highlighting
code. This is no longer necessary as the Stream class now has built-in support for
automatically counting the bytes that were written to it so far.
The advantage of automatic byte counting via Stream is that it is less error-prone
than the manual version and we need to write less boilerplate code.
Reviewers: labath
Reviewed By: labath
Subscribers: labath, lldb-commits
Differential Revision: https://reviews.llvm.org/D50676
llvm-svn: 339695
diff --git a/lldb/source/Core/Highlighter.cpp b/lldb/source/Core/Highlighter.cpp
index 2ef99c8..53aa16d 100644
--- a/lldb/source/Core/Highlighter.cpp
+++ b/lldb/source/Core/Highlighter.cpp
@@ -15,11 +15,8 @@
using namespace lldb_private;
-std::size_t HighlightStyle::ColorStyle::Apply(Stream &s,
- llvm::StringRef value) const {
+void HighlightStyle::ColorStyle::Apply(Stream &s, llvm::StringRef value) const {
s << m_prefix << value << m_suffix;
- // Calculate how many bytes we have written.
- return m_prefix.size() + value.size() + m_suffix.size();
}
void HighlightStyle::ColorStyle::Set(llvm::StringRef prefix,
@@ -28,13 +25,11 @@
m_suffix = lldb_utility::ansi::FormatAnsiTerminalCodes(suffix);
}
-std::size_t NoHighlighter::Highlight(const HighlightStyle &options,
- llvm::StringRef line,
- llvm::StringRef previous_lines,
- Stream &s) const {
+void NoHighlighter::Highlight(const HighlightStyle &options,
+ llvm::StringRef line,
+ llvm::StringRef previous_lines, Stream &s) const {
// We just forward the input to the output and do no highlighting.
s << line;
- return line.size();
}
static HighlightStyle::ColorStyle GetColor(const char *c) {