Export of internal Abseil changes

--
5d05c54a619a969da5b4b7f66a2af2d969dc7920 by Abseil Team <absl-team@google.com>:

Save not needed copies of the predicate in raw_hash_set's EraseIf.

PiperOrigin-RevId: 392706073

--
61ee9b808cd3c81dd10a600c8de5428d6a43cfeb by Abseil Team <absl-team@google.com>:

Save unnecessary copies of the iterator in raw_hash_set's EraseIf.

PiperOrigin-RevId: 392668288
GitOrigin-RevId: 5d05c54a619a969da5b4b7f66a2af2d969dc7920
Change-Id: I180dab2706841ce56f27cf6eabdad1106ebdcf73
pull/1008/head
Abseil Team 4 years ago committed by rogeeff
parent 9134967d01
commit 095dfc24ff
  1. 9
      absl/container/internal/raw_hash_set.h

@ -1921,11 +1921,12 @@ class raw_hash_set {
// Erases all elements that satisfy the predicate `pred` from the container `c`.
template <typename P, typename H, typename E, typename A, typename Predicate>
void EraseIf(Predicate pred, raw_hash_set<P, H, E, A>* c) {
void EraseIf(Predicate& pred, raw_hash_set<P, H, E, A>* c) {
for (auto it = c->begin(), last = c->end(); it != last;) {
auto copy_it = it++;
if (pred(*copy_it)) {
c->erase(copy_it);
if (pred(*it)) {
c->erase(it++);
} else {
++it;
}
}
}

Loading…
Cancel
Save