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/UserSettingsController.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/UserSettingsController.cpp')
| -rw-r--r-- | lldb/source/Core/UserSettingsController.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index 00fbc4b8a9b..92c3c8440d1 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -24,7 +24,7 @@ using namespace lldb; using namespace lldb_private; lldb::OptionValueSP -Properties::GetPropertyValue(const ExecutionContext *exe_ctx, const char *path, +Properties::GetPropertyValue(const ExecutionContext *exe_ctx, llvm::StringRef path, bool will_modify, Error &error) const { OptionValuePropertiesSP properties_sp(GetValueProperties()); if (properties_sp) @@ -33,8 +33,8 @@ Properties::GetPropertyValue(const ExecutionContext *exe_ctx, const char *path, } Error Properties::SetPropertyValue(const ExecutionContext *exe_ctx, - VarSetOperationType op, const char *path, - const char *value) { + VarSetOperationType op, llvm::StringRef path, + llvm::StringRef value) { OptionValuePropertiesSP properties_sp(GetValueProperties()); if (properties_sp) return properties_sp->SetSubValue(exe_ctx, op, path, value); @@ -60,7 +60,7 @@ void Properties::DumpAllDescriptions(CommandInterpreter &interpreter, } Error Properties::DumpPropertyValue(const ExecutionContext *exe_ctx, - Stream &strm, const char *property_path, + Stream &strm, llvm::StringRef property_path, uint32_t dump_mask) { OptionValuePropertiesSP properties_sp(GetValueProperties()); if (properties_sp) { @@ -93,16 +93,11 @@ Properties::GetSubProperty(const ExecutionContext *exe_ctx, const char *Properties::GetExperimentalSettingsName() { return "experimental"; } -bool Properties::IsSettingExperimental(const char *setting) { - if (setting == nullptr) +bool Properties::IsSettingExperimental(llvm::StringRef setting) { + if (setting.empty()) return false; - const char *experimental = GetExperimentalSettingsName(); - const char *dot_pos = strchr(setting, '.'); - if (dot_pos == nullptr) - return strcmp(experimental, setting) == 0; - else { - size_t first_elem_len = dot_pos - setting; - return strncmp(experimental, setting, first_elem_len) == 0; - } + llvm::StringRef experimental = GetExperimentalSettingsName(); + size_t dot_pos = setting.find_first_of('.'); + return setting.take_front(dot_pos) == experimental; } |

