[Lldb-commits] [lldb] [lldb] Avoid unnecessary regex check in dwim-print (PR #114608)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 7 18:28:31 PST 2025
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/114608
>From e1c631e49474027c65fc8f14a0d6baafbbf704be Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at 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 | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 04142427717bd..091cab20bb82b 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,17 +114,13 @@ 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 swift_class_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;
-
result.AppendNote(
"object description requested, but type doesn't implement "
"a custom object description. Consider using \"p\" instead of "
More information about the lldb-commits
mailing list