[Lldb-commits] [PATCH] D122426: [lldb/Utility] Make `StructuredData::Dictionary::GetKeys1 return an `Array`

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 24 12:20:48 PDT 2022


mib created this revision.
mib added reviewers: JDevlieghere, kastiglione.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

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.

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122426

Files:
  lldb/include/lldb/Utility/StructuredData.h


Index: lldb/include/lldb/Utility/StructuredData.h
===================================================================
--- lldb/include/lldb/Utility/StructuredData.h
+++ lldb/include/lldb/Utility/StructuredData.h
@@ -375,15 +375,15 @@
       }
     }
 
-    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 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122426.418016.patch
Type: text/x-patch
Size: 846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220324/a5086ba2/attachment.bin>


More information about the lldb-commits mailing list