diff options
author | Zachary Turner <zturner@google.com> | 2016-11-17 18:08:12 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-11-17 18:08:12 +0000 |
commit | 31d97a5c8ab78c619deada0cdb1fcf64021d25dd (patch) | |
tree | a1f642a22b8975a80013c7ab8bc98a7ea763346e /lldb/source/Core/Debugger.cpp | |
parent | ff0382c16190cd2b1bc47b27c5db0570b90f1d39 (diff) | |
download | bcm5719-llvm-31d97a5c8ab78c619deada0cdb1fcf64021d25dd.tar.gz bcm5719-llvm-31d97a5c8ab78c619deada0cdb1fcf64021d25dd.zip |
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
Diffstat (limited to 'lldb/source/Core/Debugger.cpp')
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
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()); |