https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/114608
None >From e244e4557a618c6d532f9d369624234ad739cf11 Mon Sep 17 00:00:00 2001 From: Dave Lee <davelee....@gmail.com> Date: Fri, 1 Nov 2024 14:38:19 -0700 Subject: [PATCH] [lldb] Avoid unnecessary regex check in dwim-print --- lldb/source/Commands/CommandObjectDWIMPrint.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp index 76bed100dc7291..ae35f6e43f6c62 100644 --- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp +++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp @@ -101,6 +101,10 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, // Add a hint if object description was requested, but no description // function was implemented. auto maybe_add_hint = [&](llvm::StringRef output) { + static bool note_shown = false; + if (note_shown) + return; + // Identify the default output of object description for Swift and // Objective-C // "<Name: 0x...>. The regex is: @@ -110,20 +114,16 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, // - Followed by 5 or more hex digits. // - Followed by ">". // - End with zero or more whitespace characters. - const std::regex swift_class_regex("^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$"); + static const std::regex class_po_regex("^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$"); if (GetDebugger().GetShowDontUsePoHint() && target_ptr && (language == lldb::eLanguageTypeSwift || language == lldb::eLanguageTypeObjC) && - std::regex_match(output.data(), swift_class_regex)) { - - static bool note_shown = false; - if (note_shown) - return; + std::regex_match(output.data(), class_po_regex)) { result.GetOutputStream() - << "note: object description requested, but type doesn't implement " - "a custom object description. Consider using \"p\" instead of " + << "note: object description requested, but type doesn't implement a " + "custom object description. Consider using \"p\" instead of " "\"po\" (this note will only be shown once per debug session).\n"; note_shown = true; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits