From 31d97a5c8ab78c619deada0cdb1fcf64021d25dd Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Thu, 17 Nov 2016 18:08:12 +0000 Subject: Rewrite all Property related functions in terms of StringRef. This was a bit tricky, especially for things like OptionValueArray and OptionValueDictionary since they do some funky string parsing. Rather than try to re-write line-by-line I tried to make the StringRef usage idiomatic, even though it meant often re-writing from scratch large blocks of code in a different way while keeping true to the original intent. The finished code is a big improvement though, and often much shorter than the original code. All tests and unit tests pass on Windows and Linux. llvm-svn: 287242 --- lldb/source/Core/Debugger.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lldb/source/Core/Debugger.cpp') diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 24715ec2129..e66fb2358df 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -276,11 +276,9 @@ LoadPluginCallbackType Debugger::g_load_plugin_callback = nullptr; Error Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, - const char *property_path, const char *value) { - bool is_load_script = - strcmp(property_path, "target.load-script-from-symbol-file") == 0; - bool is_escape_non_printables = - strcmp(property_path, "escape-non-printables") == 0; + llvm::StringRef property_path, llvm::StringRef value) { + bool is_load_script = (property_path == "target.load-script-from-symbol-file"); + bool is_escape_non_printables = (property_path == "escape-non-printables"); TargetSP target_sp; LoadScriptFromSymFile load_script_old_value; if (is_load_script && exe_ctx->GetTargetSP()) { @@ -291,7 +289,7 @@ Error Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, Error error(Properties::SetPropertyValue(exe_ctx, op, property_path, value)); if (error.Success()) { // FIXME it would be nice to have "on-change" callbacks for properties - if (strcmp(property_path, g_properties[ePropertyPrompt].name) == 0) { + if (property_path == g_properties[ePropertyPrompt].name) { llvm::StringRef new_prompt = GetPrompt(); std::string str = lldb_utility::ansi::FormatAnsiTerminalCodes( new_prompt, GetUseColor()); @@ -302,8 +300,7 @@ Error Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, new Event(CommandInterpreter::eBroadcastBitResetPrompt, new EventDataBytes(new_prompt))); GetCommandInterpreter().BroadcastEvent(prompt_change_event_sp); - } else if (strcmp(property_path, g_properties[ePropertyUseColor].name) == - 0) { + } else if (property_path == g_properties[ePropertyUseColor].name) { // use-color changed. Ping the prompt so it can reset the ansi terminal // codes. SetPrompt(GetPrompt()); -- cgit v1.2.3