Skip to content

Commit 0353a86

Browse files
committed
[lldb/Utility] Make StructuredData::Dictionary::GetKeys return an Array
This patch changes `StructuredData::Dictionary::GetKeys` return type from an `StructuredData::ObjectSP` to a `StructuredData::ArraySP`. The function already stored the keys in an array but implicitely upcasted it to an `ObjectSP`, which required the user to convert it again to a Array object to access each element. Since we know the keys should be held by an iterable container, it makes more sense to return the allocated ArraySP as-is. Differential Revision: https://reviews.llvm.org/D122426 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 0a28e4d commit 0353a86

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lldb/include/lldb/Utility/StructuredData.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,15 @@ class StructuredData {
376376
}
377377
}
378378

379-
ObjectSP GetKeys() const {
380-
auto object_sp = std::make_shared<Array>();
379+
ArraySP GetKeys() const {
380+
auto array_sp = std::make_shared<Array>();
381381
collection::const_iterator iter;
382382
for (iter = m_dict.begin(); iter != m_dict.end(); ++iter) {
383383
auto key_object_sp = std::make_shared<String>();
384384
key_object_sp->SetValue(iter->first.AsCString());
385-
object_sp->Push(key_object_sp);
385+
array_sp->Push(key_object_sp);
386386
}
387-
return object_sp;
387+
return array_sp;
388388
}
389389

390390
ObjectSP GetValueForKey(llvm::StringRef key) const {

0 commit comments

Comments
 (0)