Files
clang-p2996/lldb/source/Utility
Felipe de Azevedo Piovezan 25495c9b4c [lldb][NFCI] Remove n^2 loops and simplify iterator usage
The code inside Broadcaster makes usage of iterators using olden C++ coding
style. Hidden in this old style is a couple of N^2 loops: we iterate over a map
(sequentially), removing the first element that matches some predicate. The
search is _always_ done from the start of the map, which implies that, if the
map has N elements and if all matches happen on the second half of the map, then
we visit the first N/2 elements exactly N/2 * N/2 times.

Ideally some of the code here would benefit from `std::map`s own "erase_if", but
this is only available with C++20:
https://en.cppreference.com/w/cpp/container/map/erase_if

We spent quite some time trying to make these loops more elegant, but it is
surprisingly tricky to do so.

Differential Revision: https://reviews.llvm.org/D150219
2023-05-10 06:18:27 -04:00
..
2023-05-09 10:40:42 -07:00