[Lldb-commits] [lldb] [lldb] refactor highlighting function for image lookup command (PR #76112)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Fri Jan 19 03:44:46 PST 2024
================
@@ -72,23 +72,20 @@ size_t Stream::PutCString(llvm::StringRef str) {
return bytes_written;
}
-void Stream::PutCStringColorHighlighted(llvm::StringRef text,
- llvm::StringRef pattern,
- llvm::StringRef prefix,
- llvm::StringRef suffix) {
- // Only apply color formatting when a pattern is present and both prefix and
- // suffix are specified. In the absence of these conditions, output the text
- // without color formatting.
- if (pattern.empty() || (prefix.empty() && suffix.empty())) {
+void Stream::PutCStringColorHighlighted(
+ llvm::StringRef text, std::optional<HighlightSettings> pattern_info) {
+ // Only apply color formatting when a pattern information is specified.
+ // Otherwise, output the text without color formatting.
----------------
DavidSpickett wrote:
To link back to my earlier comment, this early exit is fine and should stay.
I think, however, that it's best for callers to pass `nullopt` for the settings if they want to disable highlighting. That's a much more intuitive way to do it, backed up by the type system.
Which is what you're doing, so don't change anything! (just wanted to explain my thinking here)
https://github.com/llvm/llvm-project/pull/76112
More information about the lldb-commits
mailing list