Skip to content

Commit e1c631e

Browse files
committed
[lldb] Avoid unnecessary regex check in dwim-print
1 parent 5bc1667 commit e1c631e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lldb/source/Commands/CommandObjectDWIMPrint.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
101101
// Add a hint if object description was requested, but no description
102102
// function was implemented.
103103
auto maybe_add_hint = [&](llvm::StringRef output) {
104+
static bool note_shown = false;
105+
if (note_shown)
106+
return;
107+
104108
// Identify the default output of object description for Swift and
105109
// Objective-C
106110
// "<Name: 0x...>. The regex is:
@@ -110,17 +114,13 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
110114
// - Followed by 5 or more hex digits.
111115
// - Followed by ">".
112116
// - End with zero or more whitespace characters.
113-
const std::regex swift_class_regex("^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$");
117+
static const std::regex swift_class_regex("^<\\S+: 0x[[:xdigit:]]{5,}>\\s*$");
114118

115119
if (GetDebugger().GetShowDontUsePoHint() && target_ptr &&
116120
(language == lldb::eLanguageTypeSwift ||
117121
language == lldb::eLanguageTypeObjC) &&
118122
std::regex_match(output.data(), swift_class_regex)) {
119123

120-
static bool note_shown = false;
121-
if (note_shown)
122-
return;
123-
124124
result.AppendNote(
125125
"object description requested, but type doesn't implement "
126126
"a custom object description. Consider using \"p\" instead of "

0 commit comments

Comments
 (0)