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
diff --git a/lldb/source/Interpreter/OptionValueArgs.cpp b/lldb/source/Interpreter/OptionValueArgs.cpp
index 2cc93ab..8edec77 100644
--- a/lldb/source/Interpreter/OptionValueArgs.cpp
+++ b/lldb/source/Interpreter/OptionValueArgs.cpp
@@ -19,17 +19,12 @@
using namespace lldb_private;
size_t OptionValueArgs::GetArgs(Args &args) {
- const uint32_t size = m_values.size();
- std::vector<const char *> argv;
- for (uint32_t i = 0; i < size; ++i) {
- const char *string_value = m_values[i]->GetStringValue();
- if (string_value)
- argv.push_back(string_value);
+ args.Clear();
+ for (auto value : m_values) {
+ llvm::StringRef string_value = value->GetStringValue();
+ if (!string_value.empty())
+ args.AppendArgument(string_value);
}
- if (argv.empty())
- args.Clear();
- else
- args.SetArguments(argv.size(), &argv[0]);
return args.GetArgumentCount();
}