diff options
author | Barnabás Pőcze <pobrn@protonmail.com> | 2024-03-11 23:35:50 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2025-04-29 15:08:53 +0100 |
commit | 7c2e60f67a02d17d8c2f67ba438fdb50d51bc9f4 (patch) | |
tree | 44b4cbcdd09c3f2bb92feb64dfe2ccda082f66b6 /gcc/rust | |
parent | 102eccaf8e2f914d3afbf7acfcee19bc5b240eca (diff) | |
download | gcc-7c2e60f67a02d17d8c2f67ba438fdb50d51bc9f4.zip gcc-7c2e60f67a02d17d8c2f67ba438fdb50d51bc9f4.tar.gz gcc-7c2e60f67a02d17d8c2f67ba438fdb50d51bc9f4.tar.bz2 |
libstdc++: Optimize removal from unique assoc containers [PR112934]
Previously, calling erase(key) on both std::map and std::set
would execute that same code that std::multi{map,set} would.
However, doing that is unnecessary because std::{map,set}
guarantee that all elements are unique.
It is reasonable to expect that erase(key) is equivalent
or better than:
auto it = m.find(key);
if (it != m.end())
m.erase(it);
However, this was not the case. Fix that by adding a new
function _Rb_tree<>::_M_erase_unique() that is essentially
equivalent to the above snippet, and use this from both
std::map and std::set.
libstdc++-v3/ChangeLog:
PR libstdc++/112934
* include/bits/stl_map.h (map::erase): Use _M_erase_unique.
* include/bits/stl_set.h (set::erase): Likewise.
* include/bits/stl_tree.h (_Rb_tree::_M_erase_unique): Add.
Diffstat (limited to 'gcc/rust')
0 files changed, 0 insertions, 0 deletions