diff options
| author | Felipe de Azevedo Piovezan <fpiovezan@apple.com> | 2023-05-09 14:58:29 -0400 |
|---|---|---|
| committer | Felipe de Azevedo Piovezan <fpiovezan@apple.com> | 2023-05-10 06:18:27 -0400 |
| commit | 25495c9b4c05cb52bacdbc91ba7ee7da7b9a857c (patch) | |
| tree | 99784994dd51116091d1af32bb8e35ce355c0d25 /lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h | |
| parent | 48bbc64a8ff5e3777a76a02cffd94b3786b93203 (diff) | |
| download | llvm-25495c9b4c05cb52bacdbc91ba7ee7da7b9a857c.zip llvm-25495c9b4c05cb52bacdbc91ba7ee7da7b9a857c.tar.gz llvm-25495c9b4c05cb52bacdbc91ba7ee7da7b9a857c.tar.bz2 | |
[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
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonReadline.h')
0 files changed, 0 insertions, 0 deletions
