fdeazeve added inline comments.

================
Comment at: lldb/source/Utility/Broadcaster.cpp:381
+  for (auto begin = m_event_map.begin(), end = m_event_map.end();;) {
+    auto iter = find_if(begin, end, listener_matches_and_shared_bits);
+    if (iter == m_event_map.end())
----------------
jingham wrote:
> Why do you re-look-up `m_event_map.end()` instead of using the `end` variable 
> you defined in the `for` initializer?
> 
> std::map::erase says it only invalidates iterators to the erased element, so 
> you should be fine to use `end` here (and since you do exactly that in the 
> previous line) it should be good here too.
Yup, this was just a mistake on my part. Will address in the next version


================
Comment at: lldb/source/Utility/Broadcaster.cpp:392
     }
-    m_event_map.erase(iter);
+    iter = m_event_map.erase(iter);
   }
----------------
bulbazord wrote:
> I don't think you need to actually capture the iterator here? std::map::erase 
> doesn't invalidate existing iterators* (so `begin` and `end` are fine) and we 
> redefine `iter` at the beginning of this loop.
> 
> *:https://en.cppreference.com/w/cpp/container/map/erase
Argh, the variable `begin` shouldn't exist, it should all be `iter`, otherwise 
we're not addressing the quadratic behaviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150219

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to