[Lldb-commits] [PATCH] D150219: [lldb][NFCI] Remove n^2 loops and simplify iterator usage
Med Ismail Bennani via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue May 9 12:17:37 PDT 2023
mib added inline comments.
================
Comment at: lldb/source/Utility/Broadcaster.cpp:430
- while (true) {
- auto events_predicate =
- [&listener](const event_listener_key &input) -> bool {
- return input.second.get() == listener;
- };
- collection::iterator iter, end_iter = m_event_map.end();
- iter = find_if(m_event_map.begin(), end_iter, events_predicate);
- if (iter == end_iter)
+ auto events_predicate = [listener](const event_listener_key &input) -> bool {
+ return input.second.get() == listener;
----------------
================
Comment at: lldb/source/Utility/Broadcaster.cpp:434-439
+ for (auto iter = m_event_map.begin(), end = m_event_map.end();;) {
+ iter = find_if(iter, end, events_predicate);
+ if (iter == m_event_map.end())
break;
+ iter = m_event_map.erase(iter);
----------------
Would be nice to add a `// TODO: use 'std::map::erase_if' when moving to c++20` comment
================
Comment at: lldb/source/Utility/Broadcaster.cpp:454-459
+ for (auto iter = m_event_map.begin(), end_iter = m_event_map.end();;) {
+ iter = find_if(iter, end_iter, listener_matches);
if (iter == end_iter)
break;
+ iter = m_event_map.erase(iter);
----------------
ditto
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150219/new/
https://reviews.llvm.org/D150219
More information about the lldb-commits
mailing list