diff options
author | Nikita Popov <npopov@redhat.com> | 2024-06-25 09:01:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-25 09:01:40 +0200 |
commit | f01958137f358f4fd3e71636b187db14a37a5853 (patch) | |
tree | 6242dd989459e13732d5d0390579d501a267c8ed /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | efa8463ab90147aacd4647eb7715763978235890 (diff) | |
download | llvm-f01958137f358f4fd3e71636b187db14a37a5853.zip llvm-f01958137f358f4fd3e71636b187db14a37a5853.tar.gz llvm-f01958137f358f4fd3e71636b187db14a37a5853.tar.bz2 |
[SmallPtrSet] Add remove_if() method (#96468)
Add remove_if() method, similar to the one already present on SetVector.
It is intended to replace the following pattern:
for (Foo *Ptr : Set)
if (Pred(Ptr))
Set.erase(Ptr);
With:
Set.remove_if(Pred);
This pattern is commonly used for set intersection, where `Pred` is
something like `!OtherSet.contains(Ptr)`.
The implementation provided here is a bit more efficient than the naive
loop, because it does not require looking up the bucket during the
erase() operation again.
However, my actual motivation for this is to have a way to perform this
operation without relying on the current `std::set`-style guarantee that
erase() does not invalidate iterators. I'd like to stop making use of
tombstones in the small regime, which will make insertion operations a
good bit more efficient. However, this will invalidate iterators during
erase().
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions