20
20
using namespace lldb ;
21
21
using namespace lldb_private ;
22
22
23
- OptionValueProperties::OptionValueProperties (ConstString name) : m_name(name) {}
23
+ OptionValueProperties::OptionValueProperties (llvm::StringRef name)
24
+ : m_name(name.str()) {}
24
25
25
26
void OptionValueProperties::Initialize (const PropertyDefinitions &defs) {
26
27
for (const auto &definition : defs) {
27
28
Property property (definition);
28
29
assert (property.IsValid ());
29
- m_name_to_index.Append (ConstString (property.GetName ()),
30
- m_properties.size ());
30
+ m_name_to_index.insert ({property.GetName (), m_properties.size ()});
31
31
property.GetValue ()->SetParent (shared_from_this ());
32
32
m_properties.push_back (property);
33
33
}
34
- m_name_to_index.Sort ();
35
34
}
36
35
37
36
void OptionValueProperties::SetValueChangedCallback (
@@ -41,24 +40,25 @@ void OptionValueProperties::SetValueChangedCallback(
41
40
property->SetValueChangedCallback (std::move (callback));
42
41
}
43
42
44
- void OptionValueProperties::AppendProperty (ConstString name,
43
+ void OptionValueProperties::AppendProperty (llvm::StringRef name,
45
44
llvm::StringRef desc, bool is_global,
46
45
const OptionValueSP &value_sp) {
47
- Property property (name. GetStringRef () , desc, is_global, value_sp);
48
- m_name_to_index.Append ( name, m_properties.size ());
46
+ Property property (name, desc, is_global, value_sp);
47
+ m_name_to_index.insert ({ name, m_properties.size ()} );
49
48
m_properties.push_back (property);
50
49
value_sp->SetParent (shared_from_this ());
51
- m_name_to_index.Sort ();
52
50
}
53
51
54
52
lldb::OptionValueSP
55
53
OptionValueProperties::GetValueForKey (const ExecutionContext *exe_ctx,
56
- ConstString key) const {
57
- lldb::OptionValueSP value_sp;
58
- size_t idx = m_name_to_index.Find (key, SIZE_MAX);
59
- if (idx < m_properties.size ())
60
- value_sp = GetPropertyAtIndex (idx, exe_ctx)->GetValue ();
61
- return value_sp;
54
+ llvm::StringRef key) const {
55
+ auto iter = m_name_to_index.find (key);
56
+ if (iter == m_name_to_index.end ())
57
+ return OptionValueSP ();
58
+ const size_t idx = iter->second ;
59
+ if (idx >= m_properties.size ())
60
+ return OptionValueSP ();
61
+ return GetPropertyAtIndex (idx, exe_ctx)->GetValue ();
62
62
}
63
63
64
64
lldb::OptionValueSP
@@ -69,13 +69,13 @@ OptionValueProperties::GetSubValue(const ExecutionContext *exe_ctx,
69
69
return OptionValueSP ();
70
70
71
71
llvm::StringRef sub_name;
72
- ConstString key;
72
+ llvm::StringRef key;
73
73
size_t key_len = name.find_first_of (" .[{" );
74
74
if (key_len != llvm::StringRef::npos) {
75
- key. SetString ( name.take_front (key_len) );
75
+ key = name.take_front (key_len);
76
76
sub_name = name.drop_front (key_len);
77
77
} else
78
- key. SetString ( name) ;
78
+ key = name;
79
79
80
80
value_sp = GetValueForKey (exe_ctx, key);
81
81
if (sub_name.empty () || !value_sp)
@@ -138,14 +138,20 @@ Status OptionValueProperties::SetSubValue(const ExecutionContext *exe_ctx,
138
138
return error;
139
139
}
140
140
141
- size_t OptionValueProperties::GetPropertyIndex (ConstString name) const {
142
- return m_name_to_index.Find (name, SIZE_MAX);
141
+ size_t OptionValueProperties::GetPropertyIndex (llvm::StringRef name) const {
142
+ auto iter = m_name_to_index.find (name);
143
+ if (iter == m_name_to_index.end ())
144
+ return SIZE_MAX;
145
+ return iter->second ;
143
146
}
144
147
145
148
const Property *
146
- OptionValueProperties::GetProperty (ConstString name,
149
+ OptionValueProperties::GetProperty (llvm::StringRef name,
147
150
const ExecutionContext *exe_ctx) const {
148
- return GetPropertyAtIndex (m_name_to_index.Find (name, SIZE_MAX), exe_ctx);
151
+ auto iter = m_name_to_index.find (name);
152
+ if (iter == m_name_to_index.end ())
153
+ return nullptr ;
154
+ return GetPropertyAtIndex (iter->second , exe_ctx);
149
155
}
150
156
151
157
lldb::OptionValueSP OptionValueProperties::GetPropertyValueAtIndex (
@@ -399,18 +405,19 @@ OptionValueProperties::DeepCopy(const OptionValueSP &new_parent) const {
399
405
const Property *
400
406
OptionValueProperties::GetPropertyAtPath (const ExecutionContext *exe_ctx,
401
407
llvm::StringRef name) const {
402
- const Property *property = nullptr ;
403
408
if (name.empty ())
404
409
return nullptr ;
410
+
411
+ const Property *property = nullptr ;
405
412
llvm::StringRef sub_name;
406
- ConstString key;
413
+ llvm::StringRef key;
407
414
size_t key_len = name.find_first_of (" .[{" );
408
415
409
416
if (key_len != llvm::StringRef::npos) {
410
- key. SetString ( name.take_front (key_len) );
417
+ key = name.take_front (key_len);
411
418
sub_name = name.drop_front (key_len);
412
419
} else
413
- key. SetString ( name) ;
420
+ key = name;
414
421
415
422
property = GetProperty (key, exe_ctx);
416
423
if (sub_name.empty () || !property)
@@ -473,7 +480,7 @@ void OptionValueProperties::Apropos(
473
480
474
481
lldb::OptionValuePropertiesSP
475
482
OptionValueProperties::GetSubProperty (const ExecutionContext *exe_ctx,
476
- ConstString name) {
483
+ llvm::StringRef name) {
477
484
lldb::OptionValueSP option_value_sp (GetValueForKey (exe_ctx, name));
478
485
if (option_value_sp) {
479
486
OptionValueProperties *ov_properties = option_value_sp->GetAsProperties ();
0 commit comments