[Lldb-commits] [PATCH] D122429: [lldb/Plugin] Sort the ScriptedProcess' thread list before creating threads

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 25 14:54:07 PDT 2022


mib added inline comments.


================
Comment at: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp:321-342
+  auto sort_keys = [&sorted_threads,
+                    &thread_info_sp](StructuredData::Object *item) -> bool {
+    if (!item)
+      return false;
+
+    llvm::StringRef key = item->GetStringValue();
+    size_t idx = 0;
----------------
JDevlieghere wrote:
> Instead of this callback, can we simplify the code by iterating over the keys and populate the map that way?
We don't have iterators to iterate over `StructuredData` containers with a range-based loop, so we can only iterate over them using indices ...

I find it ungracious to do it that way because we have to call `GetItemAtIndex(idx)` to get the `StructuredData::Object` element from the array, that's why I used the `ForEach` method instead.

I think we can improve StructuredData containers to be more customizable and operate better with the `std`/`adl` utilities, it should be done separately.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122429/new/

https://reviews.llvm.org/D122429



More information about the lldb-commits mailing list