Skip to content

Commit

Permalink
Use base::EraseIf()
Browse files Browse the repository at this point in the history
This patch is just a code simplification.

It's much easier to write:
  base::EraseIf(container, ...);
than:
  container.erase(std::remove_if(container.begin(),
      container.end(), ...), container.end());

Bug: 875665
Change-Id: Ia0c5117462a5921cf05724d1de75ecafcac65e01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4876513
Reviewed-by: Bo Liu <boliu@chromium.org>
Commit-Queue: Bo Liu <boliu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1198364}
  • Loading branch information
s1tantray authored and Chromium LUCI CQ committed Sep 19, 2023
1 parent 2caa96a commit c96dbf5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ Ryuan Choi <ryuan.choi@samsung.com>
Saikrishna Arcot <saiarcot895@gmail.com>
Sajal Khandelwal <skhandelwa22@bloomberg.net>
Sajeesh Sidharthan <sajeesh.sidharthan@amd.corp-partner.google.com>
Sakib Shabir <s1.tantray@samsung.com>
Saksham Mittal <gotlouemail@gmail.com>
Salvatore Iovene <salvatore.iovene@intel.com>
Sam James <sam@gentoo.org>
Expand Down
12 changes: 4 additions & 8 deletions content/browser/interest_group/interest_group_auction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3305,14 +3305,10 @@ void InterestGroupAuction::OnInterestGroupRead(
}

// Ignore interest groups with no bidding script or no ads.
interest_groups.erase(
std::remove_if(interest_groups.begin(), interest_groups.end(),
[](const StorageInterestGroup& bidder) {
return !bidder.interest_group.bidding_url ||
!bidder.interest_group.ads ||
bidder.interest_group.ads->empty();
}),
interest_groups.end());
base::EraseIf(interest_groups, [](const StorageInterestGroup& bidder) {
return !bidder.interest_group.bidding_url || !bidder.interest_group.ads ||
bidder.interest_group.ads->empty();
});

// Ignore interest groups that don't provide the requested seller
// capabilities.
Expand Down
10 changes: 3 additions & 7 deletions content/browser/preloading/prerenderer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,9 @@ void PrerendererImpl::ProcessCandidatesForPrerender(
// requests rejected by PrerenderHostRegistry can be filtered out. But
// ideally PrerenderHostRegistry should implement the history management
// mechanism by itself.
started_prerenders_.erase(
std::remove_if(started_prerenders_.begin(), started_prerenders_.end(),
[&](const PrerenderInfo& x) {
return base::Contains(removed_prerender_rules_set,
x.prerender_host_id);
}),
started_prerenders_.end());
base::EraseIf(started_prerenders_, [&](const PrerenderInfo& x) {
return base::Contains(removed_prerender_rules_set, x.prerender_host_id);
});
}

// Actually start the candidates once the diffing is done.
Expand Down

0 comments on commit c96dbf5

Please sign in to comment.