Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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().
- Loading branch information