[PATCH][_GLIBCXX_DEBUG] Limit performance impact in __erase_nodes_if
François Dumont
frs.dumont@gmail.com
Thu Nov 18 22:04:16 GMT 2021
Hi
Here is a proposal to limit performance impact of _GLIBCXX_DEBUG
mode on __erase_nodes_if.
As you can see I am adding erase overloads on the Debug container
to accept base iterators. So it exposes an additional non-Standard
method, do you think it is any issue.
Note that I've started doing something similar for the vector/deque
adding this time erase(_Base_const_iterator, _Base_const_iterator)
overloads. But in this case it results in ambiguous erase calls, even if
I remove the _Safe_iterator cast operator to the base iterator.
libstdc++: [_GLIBCXX_DEBUG] Reduce performance impact on std::erase_if
Bypass the _GLIBCXX_DEBUG additional checks in
std::__detail::__erase_node_if used
by all implementations of std::erase_if for node based containers.
libstdc++-v3/ChangeLog:
* include/bits/erase_if.h (__erase_nodes_if): Add
_UnsafeContainer template
parameter. Use it to get iterators to work with.
* include/debug/macros.h (__glibcxx_check_erase2): New.
* include/debug/map.h (map<>::erase(_Base_const_iterator)):
New.
(map<>::erase(const_iterator)): Use latter.
* include/debug/multimap.h
(multimap<>::erase(_Base_const_iterator)): New.
(multimap<>::erase(const_iterator)): Use latter.
* include/debug/multiset.h
(multiset<>::erase(_Base_const_iterator)): New.
(multiset<>::erase(const_iterator)): Use latter.
* include/debug/set.h (set<>::erase(_Base_const_iterator)):
New.
(set<>::erase(const_iterator)): Use latter.
* include/debug/unordered_map
(unordered_map<>::erase(_Base_const_iterator)): New.
(unordered_multimap<>::erase(const_iterator)): New.
* include/debug/unordered_set
(unordered_set<>::erase(_Base_const_iterator)): New.
(unordered_multiset<>::erase(const_iterator)): New.
* include/experimental/map (erase_if): Adapt.
* include/experimental/set (erase_if): Adapt.
* include/experimental/unordered_map (erase_if): Adapt.
* include/experimental/unordered_set (erase_if): Adapt.
* include/std/map (erase_if): Adapt.
* include/std/set (erase_if): Adapt.
* include/std/unordered_map (erase_if): Adapt.
* include/std/unordered_set (erase_if): Adapt.
Tested under Linux x86_64,
Ok to commit ?
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: erase_node_if.patch
Type: text/x-patch
Size: 15715 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20211118/9a2df3a7/attachment-0001.bin>
More information about the Libstdc++
mailing list