================
@@ -3098,6 +3107,23 @@ void Target::SetAllStopHooksActiveState(bool
active_state) {
}
}
+// FIXME: Ideally we would like to return a `const &` (const reference)
instead
----------------
yln wrote:
```
typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
StopHookCollection m_stop_hooks;
```
Iteration order of `std::map` is defined by its keys (ascending).
Previously, we were *also* using `std::map` iteration order, just in a really
convoluted/inefficient way:
```
size_t GetNumStopHooks() const { return m_stop_hooks.size(); }
StopHookSP GetStopHookAtIndex(size_t index) { // <<< this is 0-based index,
not the "user ID"
if (index >= GetNumStopHooks())
return StopHookSP();
StopHookCollection::iterator pos = m_stop_hooks.begin(); // <<< std::map
iterator
while (index > 0) {
pos++;
index--;
}
return (*pos).second;
}
// Call sites:
size_t num_hooks = target.GetNumStopHooks();
for (size_t i = 0; i < num_hooks; i++) {
Target::StopHookSP hook = target.GetStopHookAtIndex(i);
...
}
```
https://github.com/llvm/llvm-project/pull/164506
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits