[Lldb-commits] [lldb] 29f3636 - [lldb/Utility] Make StructuredData::Dictionary::GetKeys return an Array
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 25 15:00:27 PDT 2022
Author: Med Ismail Bennani
Date: 2022-03-25T14:59:50-07:00
New Revision: 29f363611dd4b9b898230cde60bacf71f9581343
URL: https://github.com/llvm/llvm-project/commit/29f363611dd4b9b898230cde60bacf71f9581343
DIFF: https://github.com/llvm/llvm-project/commit/29f363611dd4b9b898230cde60bacf71f9581343.diff
LOG: [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 <medismail.bennani at gmail.com>
Added:
Modified:
lldb/include/lldb/Utility/StructuredData.h
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/StructuredData.h b/lldb/include/lldb/Utility/StructuredData.h
index 11eee92f8c3b8..9f6300f4f115b 100644
--- a/lldb/include/lldb/Utility/StructuredData.h
+++ b/lldb/include/lldb/Utility/StructuredData.h
@@ -375,15 +375,15 @@ class StructuredData {
}
}
- ObjectSP GetKeys() const {
- auto object_sp = std::make_shared<Array>();
+ ArraySP GetKeys() const {
+ auto array_sp = std::make_shared<Array>();
collection::const_iterator iter;
for (iter = m_dict.begin(); iter != m_dict.end(); ++iter) {
auto key_object_sp = std::make_shared<String>();
key_object_sp->SetValue(iter->first.AsCString());
- object_sp->Push(key_object_sp);
+ array_sp->Push(key_object_sp);
}
- return object_sp;
+ return array_sp;
}
ObjectSP GetValueForKey(llvm::StringRef key) const {
More information about the lldb-commits
mailing list