Commit a248d5c3 authored by Jdragon's avatar Jdragon Committed by Commit Bot

Use base::Erase(), base::EraseIf() in components/

This patch is just a code simplification.

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

Bug: 875665
Change-Id: I4eb9f77b58befd58c6c978eb7ce591b5d95bd613
Reviewed-on: https://chromium-review.googlesource.com/1181483Reviewed-by: default avatarJinho Bang <jinho.bang@samsung.com>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Jinho Bang <jinho.bang@samsung.com>
Cr-Commit-Position: refs/heads/master@{#585811}
parent 8d17bf2d
...@@ -350,6 +350,7 @@ Jaehyun Lee <j-hyun.lee@samsung.com> ...@@ -350,6 +350,7 @@ Jaehyun Lee <j-hyun.lee@samsung.com>
Jaekyeom Kim <btapiz@gmail.com> Jaekyeom Kim <btapiz@gmail.com>
Jaemin Seo <jaemin86.seo@samsung.com> Jaemin Seo <jaemin86.seo@samsung.com>
Jaeseok Yoon <yjaeseok@gmail.com> Jaeseok Yoon <yjaeseok@gmail.com>
Jaeyong Bae <jdragon.bae@gmail.com>
Jaime Soriano Pastor <jsorianopastor@gmail.com> Jaime Soriano Pastor <jsorianopastor@gmail.com>
Jake Helfert <jake@helfert.us> Jake Helfert <jake@helfert.us>
Jake Hendy <me@jakehendy.com> Jake Hendy <me@jakehendy.com>
......
...@@ -210,14 +210,10 @@ void RemoveFieldsWithNegativeWords( ...@@ -210,14 +210,10 @@ void RemoveFieldsWithNegativeWords(
kNegativeLatin, kNegativeLatinSize, kNegativeNonLatin, kNegativeLatin, kNegativeLatinSize, kNegativeNonLatin,
kNegativeNonLatinSize}; kNegativeNonLatinSize};
possible_usernames_data->erase( base::EraseIf(
std::remove_if(possible_usernames_data->begin(), *possible_usernames_data, [](const UsernameFieldData& possible_username) {
possible_usernames_data->end(), return ContainsWordFromCategory(possible_username, kNegativeCategory);
[](const UsernameFieldData& possible_username) { });
return ContainsWordFromCategory(possible_username,
kNegativeCategory);
}),
possible_usernames_data->end());
} }
// Check if any word from the given category (|category|) appears in fields from // Check if any word from the given category (|category|) appears in fields from
......
...@@ -404,14 +404,10 @@ void AutofillExternalDelegate::InsertDataListValues( ...@@ -404,14 +404,10 @@ void AutofillExternalDelegate::InsertDataListValues(
// the list of datalist values. // the list of datalist values.
std::set<base::string16> data_list_set(data_list_values_.begin(), std::set<base::string16> data_list_set(data_list_values_.begin(),
data_list_values_.end()); data_list_values_.end());
suggestions->erase( base::EraseIf(*suggestions, [&data_list_set](const Suggestion& suggestion) {
std::remove_if( return suggestion.frontend_id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY &&
suggestions->begin(), suggestions->end(), base::ContainsKey(data_list_set, suggestion.value);
[&data_list_set](const Suggestion& suggestion) { });
return suggestion.frontend_id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY &&
base::ContainsKey(data_list_set, suggestion.value);
}),
suggestions->end());
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
// Insert the separator between the datalist and Autofill/Autocomplete values // Insert the separator between the datalist and Autofill/Autocomplete values
......
...@@ -1705,9 +1705,7 @@ void PersonalDataManager::SetProfiles(std::vector<AutofillProfile>* profiles) { ...@@ -1705,9 +1705,7 @@ void PersonalDataManager::SetProfiles(std::vector<AutofillProfile>* profiles) {
return; return;
// Remove empty profiles from input. // Remove empty profiles from input.
profiles->erase(std::remove_if(profiles->begin(), profiles->end(), base::EraseIf(*profiles, IsEmptyFunctor<AutofillProfile>(app_locale_));
IsEmptyFunctor<AutofillProfile>(app_locale_)),
profiles->end());
if (!database_helper_->GetLocalDatabase()) if (!database_helper_->GetLocalDatabase())
return; return;
...@@ -1748,9 +1746,7 @@ void PersonalDataManager::SetCreditCards( ...@@ -1748,9 +1746,7 @@ void PersonalDataManager::SetCreditCards(
return; return;
// Remove empty credit cards from input. // Remove empty credit cards from input.
credit_cards->erase(std::remove_if(credit_cards->begin(), credit_cards->end(), base::EraseIf(*credit_cards, IsEmptyFunctor<CreditCard>(app_locale_));
IsEmptyFunctor<CreditCard>(app_locale_)),
credit_cards->end());
if (!database_helper_->GetLocalDatabase()) if (!database_helper_->GetLocalDatabase())
return; return;
......
...@@ -208,17 +208,13 @@ void ChromeRequireCTDelegate::UpdateCTPolicies( ...@@ -208,17 +208,13 @@ void ChromeRequireCTDelegate::UpdateCTPolicies(
ParseSpkiHashes(excluded_legacy_spkis, &legacy_spkis_); ParseSpkiHashes(excluded_legacy_spkis, &legacy_spkis_);
// Filter out SPKIs that aren't for legacy CAs. // Filter out SPKIs that aren't for legacy CAs.
legacy_spkis_.erase( base::EraseIf(legacy_spkis_, [](const net::HashValue& hash) {
std::remove_if(legacy_spkis_.begin(), legacy_spkis_.end(), if (!net::IsLegacyPubliclyTrustedCA(hash)) {
[](const net::HashValue& hash) { LOG(ERROR) << "Non-legacy SPKI configured " << hash.ToString();
if (!net::IsLegacyPubliclyTrustedCA(hash)) { return true;
LOG(ERROR) << "Non-legacy SPKI configured " }
<< hash.ToString(); return false;
return true; });
}
return false;
}),
legacy_spkis_.end());
} }
bool ChromeRequireCTDelegate::MatchHostname(const std::string& hostname, bool ChromeRequireCTDelegate::MatchHostname(const std::string& hostname,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "components/crash/content/app/minidump_with_crashpad_info.h" #include "components/crash/content/app/minidump_with_crashpad_info.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/stl_util.h"
#include "third_party/crashpad/crashpad/client/crash_report_database.h" #include "third_party/crashpad/crashpad/client/crash_report_database.h"
#include "third_party/crashpad/crashpad/client/crashpad_info.h" #include "third_party/crashpad/crashpad/client/crashpad_info.h"
#include "third_party/crashpad/crashpad/client/settings.h" #include "third_party/crashpad/crashpad/client/settings.h"
...@@ -74,11 +75,9 @@ bool MinidumpUpdater::Initialize(base::File* file) { ...@@ -74,11 +75,9 @@ bool MinidumpUpdater::Initialize(base::File* file) {
// Start by removing any unused directory entries. // Start by removing any unused directory entries.
// TODO(siggi): Fix Crashpad to ignore unused streams. // TODO(siggi): Fix Crashpad to ignore unused streams.
directory_.erase(std::remove_if(directory_.begin(), directory_.end(), base::EraseIf(directory_, [](const MINIDUMP_DIRECTORY& entry) {
[](const MINIDUMP_DIRECTORY& entry) { return entry.StreamType == UnusedStream;
return entry.StreamType == UnusedStream; });
}),
directory_.end());
// Update the header. // Update the header.
// TODO(siggi): Fix Crashpad's version checking. // TODO(siggi): Fix Crashpad's version checking.
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/process/memory.h" #include "base/process/memory.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "components/browser_watcher/stability_report_user_stream_data_source.h" #include "components/browser_watcher/stability_report_user_stream_data_source.h"
...@@ -52,17 +53,14 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line, ...@@ -52,17 +53,14 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line,
base::string16(L"--") + base::UTF8ToUTF16(process_type_switch) + L"="; base::string16(L"--") + base::UTF8ToUTF16(process_type_switch) + L"=";
const base::string16 user_data_dir_arg_prefix = const base::string16 user_data_dir_arg_prefix =
base::string16(L"--") + base::UTF8ToUTF16(user_data_dir_switch) + L"="; base::string16(L"--") + base::UTF8ToUTF16(user_data_dir_switch) + L"=";
argv.erase( base::EraseIf(argv, [&process_type_arg_prefix,
std::remove_if(argv.begin(), argv.end(), &user_data_dir_arg_prefix](const base::string16& str) {
[&process_type_arg_prefix, return base::StartsWith(str, process_type_arg_prefix,
&user_data_dir_arg_prefix](const base::string16& str) { base::CompareCase::SENSITIVE) ||
return base::StartsWith(str, process_type_arg_prefix, base::StartsWith(str, user_data_dir_arg_prefix,
base::CompareCase::SENSITIVE) || base::CompareCase::SENSITIVE) ||
base::StartsWith(str, user_data_dir_arg_prefix, (!str.empty() && str[0] == L'/');
base::CompareCase::SENSITIVE) || });
(!str.empty() && str[0] == L'/');
}),
argv.end());
std::unique_ptr<char* []> argv_as_utf8(new char*[argv.size() + 1]); std::unique_ptr<char* []> argv_as_utf8(new char*[argv.size() + 1]);
std::vector<std::string> storage; std::vector<std::string> storage;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include "base/callback.h" #include "base/callback.h"
#include "base/stl_util.h"
#include "components/cryptauth/wire_message.h" #include "components/cryptauth/wire_message.h"
namespace cryptauth { namespace cryptauth {
...@@ -49,9 +50,7 @@ void FakeConnection::AddObserver(ConnectionObserver* observer) { ...@@ -49,9 +50,7 @@ void FakeConnection::AddObserver(ConnectionObserver* observer) {
} }
void FakeConnection::RemoveObserver(ConnectionObserver* observer) { void FakeConnection::RemoveObserver(ConnectionObserver* observer) {
observers_.erase( base::Erase(observers_, observer);
std::remove(observers_.begin(), observers_.end(), observer),
observers_.end());
Connection::RemoveObserver(observer); Connection::RemoveObserver(observer);
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/time/default_tick_clock.h" #include "base/time/default_tick_clock.h"
#include "base/time/tick_clock.h" #include "base/time/tick_clock.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h"
...@@ -98,12 +99,10 @@ void DataReductionProxyDelegate::OnResolveProxy( ...@@ -98,12 +99,10 @@ void DataReductionProxyDelegate::OnResolveProxy(
: config_->GetProxiesForHttp(); : config_->GetProxiesForHttp();
// Remove the proxies that are unsupported for this request. // Remove the proxies that are unsupported for this request.
proxies_for_http.erase( base::EraseIf(proxies_for_http,
std::remove_if(proxies_for_http.begin(), proxies_for_http.end(), [content_type](const DataReductionProxyServer& proxy) {
[content_type](const DataReductionProxyServer& proxy) { return !proxy.SupportsResourceType(content_type);
return !proxy.SupportsResourceType(content_type); });
}),
proxies_for_http.end());
base::Optional<std::pair<bool /* is_secure_proxy */, bool /*is_core_proxy */>> base::Optional<std::pair<bool /* is_secure_proxy */, bool /*is_core_proxy */>>
warmup_proxy = config_->GetInFlightWarmupProxyDetails(); warmup_proxy = config_->GetInFlightWarmupProxyDetails();
...@@ -120,14 +119,11 @@ void DataReductionProxyDelegate::OnResolveProxy( ...@@ -120,14 +119,11 @@ void DataReductionProxyDelegate::OnResolveProxy(
bool is_core_proxy = warmup_proxy->second; bool is_core_proxy = warmup_proxy->second;
// Remove the proxies with properties that do not match the properties of // Remove the proxies with properties that do not match the properties of
// the proxy that is being probed. // the proxy that is being probed.
proxies_for_http.erase( base::EraseIf(proxies_for_http, [is_secure_proxy, is_core_proxy](
std::remove_if(proxies_for_http.begin(), proxies_for_http.end(), const DataReductionProxyServer& proxy) {
[is_secure_proxy, return proxy.IsSecureProxy() != is_secure_proxy ||
is_core_proxy](const DataReductionProxyServer& proxy) { proxy.IsCoreProxy() != is_core_proxy;
return proxy.IsSecureProxy() != is_secure_proxy || });
proxy.IsCoreProxy() != is_core_proxy;
}),
proxies_for_http.end());
} }
// If the proxy is disabled due to warmup URL fetch failing in the past, // If the proxy is disabled due to warmup URL fetch failing in the past,
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/location.h" #include "base/location.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "components/dom_distiller/core/distilled_content_store.h" #include "components/dom_distiller/core/distilled_content_store.h"
#include "components/dom_distiller/core/proto/distilled_article.pb.h" #include "components/dom_distiller/core/proto/distilled_article.pb.h"
...@@ -112,7 +113,7 @@ bool TaskTracker::HasUrl(const GURL& url) const { ...@@ -112,7 +113,7 @@ bool TaskTracker::HasUrl(const GURL& url) const {
} }
void TaskTracker::RemoveViewer(ViewRequestDelegate* delegate) { void TaskTracker::RemoveViewer(ViewRequestDelegate* delegate) {
viewers_.erase(std::remove(viewers_.begin(), viewers_.end(), delegate)); base::Erase(viewers_, delegate);
if (viewers_.empty()) { if (viewers_.empty()) {
MaybeCancel(); MaybeCancel();
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "components/gcm_driver/gcm_driver.h" #include "components/gcm_driver/gcm_driver.h"
...@@ -246,7 +247,7 @@ void InstanceIDImpl::EnsureIDGenerated() { ...@@ -246,7 +247,7 @@ void InstanceIDImpl::EnsureIDGenerated() {
&id_); &id_);
std::replace(id_.begin(), id_.end(), '+', '-'); std::replace(id_.begin(), id_.end(), '+', '-');
std::replace(id_.begin(), id_.end(), '/', '_'); std::replace(id_.begin(), id_.end(), '/', '_');
id_.erase(std::remove(id_.begin(), id_.end(), '='), id_.end()); base::Erase(id_, '=');
creation_time_ = base::Time::Now(); creation_time_ = base::Time::Now();
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <algorithm> #include <algorithm>
#include "base/stl_util.h"
namespace { namespace {
static constexpr int CACHE_SIZE = 5; static constexpr int CACHE_SIZE = 5;
} // namespace } // namespace
...@@ -76,12 +78,10 @@ void ContextualSuggestionsDebuggingReporter::Flush() { ...@@ -76,12 +78,10 @@ void ContextualSuggestionsDebuggingReporter::Flush() {
// Check if we've already sent an event with this url to the cache. If so, // Check if we've already sent an event with this url to the cache. If so,
// remove it before adding another one. // remove it before adding another one.
const std::string current_url = current_event_.url; const std::string current_url = current_event_.url;
auto itr = base::EraseIf(events_,
std::remove_if(events_.begin(), events_.end(), [current_url](ContextualSuggestionsDebuggingEvent event) {
[current_url](ContextualSuggestionsDebuggingEvent event) { return current_url == event.url;
return current_url == event.url; });
});
events_.erase(itr, events_.end());
events_.push_back(current_event_); events_.push_back(current_event_);
// If the cache is too large, then remove the least recently used. // If the cache is too large, then remove the least recently used.
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/trace_event/memory_usage_estimator.h" #include "base/trace_event/memory_usage_estimator.h"
...@@ -435,9 +436,7 @@ void AutocompleteResult::MaybeCullTailSuggestions(ACMatches* matches) { ...@@ -435,9 +436,7 @@ void AutocompleteResult::MaybeCullTailSuggestions(ACMatches* matches) {
// unlikely, as we normally would expect the search-what-you-typed suggestion // unlikely, as we normally would expect the search-what-you-typed suggestion
// as a default match (and that's a non-tail suggestion). // as a default match (and that's a non-tail suggestion).
if (non_tail_default == matches->end()) { if (non_tail_default == matches->end()) {
matches->erase( base::EraseIf(*matches, std::not1(is_tail));
std::remove_if(matches->begin(), matches->end(), std::not1(is_tail)),
matches->end());
return; return;
} }
// Determine if there are both tail and non-tail matches, excluding the // Determine if there are both tail and non-tail matches, excluding the
...@@ -457,8 +456,7 @@ void AutocompleteResult::MaybeCullTailSuggestions(ACMatches* matches) { ...@@ -457,8 +456,7 @@ void AutocompleteResult::MaybeCullTailSuggestions(ACMatches* matches) {
// remove the highest rated suggestions. // remove the highest rated suggestions.
if (any_tail) { if (any_tail) {
if (any_non_tail) { if (any_non_tail) {
matches->erase(std::remove_if(matches->begin(), matches->end(), is_tail), base::EraseIf(*matches, is_tail);
matches->end());
} else { } else {
// We want the non-tail default match to be first. Mark tail suggestions // We want the non-tail default match to be first. Mark tail suggestions
// as not a legal default match, so that the default match will be moved // as not a legal default match, so that the default match will be moved
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/i18n/case_conversion.h" #include "base/i18n/case_conversion.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "components/data_use_measurement/core/data_use_user_data.h" #include "components/data_use_measurement/core/data_use_user_data.h"
...@@ -506,9 +507,9 @@ void BaseSearchProvider::DeleteMatchFromMatches( ...@@ -506,9 +507,9 @@ void BaseSearchProvider::DeleteMatchFromMatches(
void BaseSearchProvider::OnDeletionComplete( void BaseSearchProvider::OnDeletionComplete(
bool success, SuggestionDeletionHandler* handler) { bool success, SuggestionDeletionHandler* handler) {
RecordDeletionResult(success); RecordDeletionResult(success);
deletion_handlers_.erase(std::remove_if( base::EraseIf(
deletion_handlers_.begin(), deletion_handlers_.end(), deletion_handlers_,
[handler](const std::unique_ptr<SuggestionDeletionHandler>& elem) { [handler](const std::unique_ptr<SuggestionDeletionHandler>& elem) {
return elem.get() == handler; return elem.get() == handler;
})); });
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/i18n/case_conversion.h" #include "base/i18n/case_conversion.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -144,9 +145,7 @@ void ShortcutsProvider::DeleteMatch(const AutocompleteMatch& match) { ...@@ -144,9 +145,7 @@ void ShortcutsProvider::DeleteMatch(const AutocompleteMatch& match) {
if (backend) // Can be NULL in Incognito. if (backend) // Can be NULL in Incognito.
backend->DeleteShortcutsWithURL(url); backend->DeleteShortcutsWithURL(url);
matches_.erase(std::remove_if(matches_.begin(), matches_.end(), base::EraseIf(matches_, DestinationURLEqualsURL(url));
DestinationURLEqualsURL(url)),
matches_.end());
// NOTE: |match| is now dead! // NOTE: |match| is now dead!
// Delete the match from the history DB. This will eventually result in a // Delete the match from the history DB. This will eventually result in a
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include "base/macros.h" #include "base/macros.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
...@@ -311,8 +312,7 @@ TEST(PasswordManagerUtil, FindBestMatches) { ...@@ -311,8 +312,7 @@ TEST(PasswordManagerUtil, FindBestMatches) {
// A non-best match form must not be in |best_matches|. // A non-best match form must not be in |best_matches|.
EXPECT_NE(best_matches[form->username_value], form); EXPECT_NE(best_matches[form->username_value], form);
matches.erase(std::remove(matches.begin(), matches.end(), form), base::Erase(matches, form);
matches.end());
} }
// Expect that all non-best matches were found in |matches| and only best // Expect that all non-best matches were found in |matches| and only best
// matches left. // matches left.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include "base/stl_util.h"
#include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/hash_password_manager.h" #include "components/password_manager/core/browser/hash_password_manager.h"
#include "components/password_manager/core/browser/password_hash_data.h" #include "components/password_manager/core/browser/password_hash_data.h"
...@@ -245,13 +246,10 @@ void PasswordReuseDetector::ClearGaiaPasswordHash(const std::string& username) { ...@@ -245,13 +246,10 @@ void PasswordReuseDetector::ClearGaiaPasswordHash(const std::string& username) {
if (!gaia_password_hash_data_list_) if (!gaia_password_hash_data_list_)
return; return;
gaia_password_hash_data_list_->erase( base::EraseIf(*gaia_password_hash_data_list_,
std::remove_if(gaia_password_hash_data_list_->begin(), [&username](const PasswordHashData& data) {
gaia_password_hash_data_list_->end(), return data.username == username;
[&username](const PasswordHashData& data) { });
return data.username == username;
}),
gaia_password_hash_data_list_->end());
} }
void PasswordReuseDetector::ClearAllGaiaPasswordHash() { void PasswordReuseDetector::ClearAllGaiaPasswordHash() {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "base/json/json_string_value_serializer.h" #include "base/json/json_string_value_serializer.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/values.h" #include "base/values.h"
...@@ -171,9 +172,7 @@ void WebUIInfoSingleton::RegisterWebUIInstance(SafeBrowsingUIHandler* webui) { ...@@ -171,9 +172,7 @@ void WebUIInfoSingleton::RegisterWebUIInstance(SafeBrowsingUIHandler* webui) {
} }
void WebUIInfoSingleton::UnregisterWebUIInstance(SafeBrowsingUIHandler* webui) { void WebUIInfoSingleton::UnregisterWebUIInstance(SafeBrowsingUIHandler* webui) {
webui_instances_.erase( base::Erase(webui_instances_, webui);
std::remove(webui_instances_.begin(), webui_instances_.end(), webui),
webui_instances_.end());
if (webui_instances_.empty()) { if (webui_instances_.empty()) {
ClearCSBRRsSent(); ClearCSBRRsSent();
ClearClientDownloadRequestsSent(); ClearClientDownloadRequestsSent();
......
...@@ -449,9 +449,7 @@ std::vector<std::string> AccountReconcilor::LoadValidAccountsFromTokenService() ...@@ -449,9 +449,7 @@ std::vector<std::string> AccountReconcilor::LoadValidAccountsFromTokenService()
} }
} }
chrome_accounts.erase(std::remove(chrome_accounts.begin(), base::Erase(chrome_accounts, std::string());
chrome_accounts.end(), std::string()),
chrome_accounts.end());
VLOG(1) << "AccountReconcilor::ValidateAccountsFromTokenService: " VLOG(1) << "AccountReconcilor::ValidateAccountsFromTokenService: "
<< "Chrome " << chrome_accounts.size() << " accounts"; << "Chrome " << chrome_accounts.size() << " accounts";
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "components/subresource_filter/tools/rule_parser/rule_parser.h" #include "components/subresource_filter/tools/rule_parser/rule_parser.h"
...@@ -277,13 +278,11 @@ TEST(RuleStreamTest, TransferRulesAndDiscardRegexpRules) { ...@@ -277,13 +278,11 @@ TEST(RuleStreamTest, TransferRulesAndDiscardRegexpRules) {
input.reset(); input.reset();
output.reset(); output.reset();
contents.url_rules.erase( base::EraseIf(contents.url_rules,
std::remove_if(contents.url_rules.begin(), contents.url_rules.end(), [](const url_pattern_index::proto::UrlRule& rule) {
[](const url_pattern_index::proto::UrlRule& rule) { return rule.url_pattern_type() ==
return rule.url_pattern_type() == url_pattern_index::proto::URL_PATTERN_TYPE_REGEXP;
url_pattern_index::proto::URL_PATTERN_TYPE_REGEXP; });
}),
contents.url_rules.end());
contents.css_rules.clear(); contents.css_rules.clear();
EXPECT_EQ(target_ruleset.ReadContents(), contents); EXPECT_EQ(target_ruleset.ReadContents(), contents);
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/base64.h" #include "base/base64.h"
#include "base/sha1.h" #include "base/sha1.h"
#include "base/stl_util.h"
#include "components/bookmarks/browser/bookmark_node.h" #include "components/bookmarks/browser/bookmark_node.h"
#include "components/sync/base/time.h" #include "components/sync/base/time.h"
#include "components/sync/base/unique_position.h" #include "components/sync/base/unique_position.h"
...@@ -169,10 +170,7 @@ void SyncedBookmarkTracker::Remove(const std::string& sync_id) { ...@@ -169,10 +170,7 @@ void SyncedBookmarkTracker::Remove(const std::string& sync_id) {
const Entity* entity = GetEntityForSyncId(sync_id); const Entity* entity = GetEntityForSyncId(sync_id);
DCHECK(entity); DCHECK(entity);
bookmark_node_to_entities_map_.erase(entity->bookmark_node()); bookmark_node_to_entities_map_.erase(entity->bookmark_node());
ordered_local_tombstones_.erase( base::Erase(ordered_local_tombstones_, entity);
std::remove(ordered_local_tombstones_.begin(),
ordered_local_tombstones_.end(), entity),
ordered_local_tombstones_.end());
sync_id_to_entities_map_.erase(sync_id); sync_id_to_entities_map_.erase(sync_id);
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "third_party/icu/source/common/unicode/uniset.h" #include "third_party/icu/source/common/unicode/uniset.h"
#include "third_party/icu/source/common/unicode/unistr.h" #include "third_party/icu/source/common/unicode/unistr.h"
...@@ -782,9 +783,7 @@ std::string ChineseScriptClassifier::Classify(const std::string& input) const { ...@@ -782,9 +783,7 @@ std::string ChineseScriptClassifier::Classify(const std::string& input) const {
base::TruncateUTF8ToByteSize(input, 500, &input_subset); base::TruncateUTF8ToByteSize(input, 500, &input_subset);
// Remove whitespace since transliterators may not preserve it. // Remove whitespace since transliterators may not preserve it.
input_subset.erase(std::remove_if(input_subset.begin(), input_subset.end(), base::EraseIf(input_subset, base::IsUnicodeWhitespace);
base::IsUnicodeWhitespace),
input_subset.end());
// Convert the input to icu::UnicodeString so we can iterate over codepoints. // Convert the input to icu::UnicodeString so we can iterate over codepoints.
icu::UnicodeString input_codepoints = icu::UnicodeString input_codepoints =
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/files/memory_mapped_file.h" #include "base/files/memory_mapped_file.h"
#include "base/json/json_file_value_serializer.h" #include "base/json/json_file_value_serializer.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
...@@ -190,10 +191,8 @@ bool IsValidInstallerAttribute(const InstallerAttribute& attr) { ...@@ -190,10 +191,8 @@ bool IsValidInstallerAttribute(const InstallerAttribute& attr) {
void RemoveUnsecureUrls(std::vector<GURL>* urls) { void RemoveUnsecureUrls(std::vector<GURL>* urls) {
DCHECK(urls); DCHECK(urls);
urls->erase(std::remove_if( base::EraseIf(*urls,
urls->begin(), urls->end(), [](const GURL& url) { return !url.SchemeIsCryptographic(); });
[](const GURL& url) { return !url.SchemeIsCryptographic(); }),
urls->end());
} }
CrxInstaller::Result InstallFunctionWrapper( CrxInstaller::Result InstallFunctionWrapper(
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "components/variations/synthetic_trial_registry.h" #include "components/variations/synthetic_trial_registry.h"
#include "base/stl_util.h"
namespace variations { namespace variations {
SyntheticTrialRegistry::SyntheticTrialRegistry() = default; SyntheticTrialRegistry::SyntheticTrialRegistry() = default;
...@@ -46,10 +48,7 @@ void SyntheticTrialRegistry::RegisterSyntheticMultiGroupFieldTrial( ...@@ -46,10 +48,7 @@ void SyntheticTrialRegistry::RegisterSyntheticMultiGroupFieldTrial(
auto has_same_trial_name = [trial_name_hash](const SyntheticTrialGroup& x) { auto has_same_trial_name = [trial_name_hash](const SyntheticTrialGroup& x) {
return x.id.name == trial_name_hash; return x.id.name == trial_name_hash;
}; };
synthetic_trial_groups_.erase( base::EraseIf(synthetic_trial_groups_, has_same_trial_name);
std::remove_if(synthetic_trial_groups_.begin(),
synthetic_trial_groups_.end(), has_same_trial_name),
synthetic_trial_groups_.end());
if (group_name_hashes.empty()) if (group_name_hashes.empty())
return; return;
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include "base/stl_util.h"
namespace zucchini { namespace zucchini {
/******** AddressTranslator::OffsetToRvaCache ********/ /******** AddressTranslator::OffsetToRvaCache ********/
...@@ -77,9 +79,7 @@ AddressTranslator::Status AddressTranslator::Initialize( ...@@ -77,9 +79,7 @@ AddressTranslator::Status AddressTranslator::Initialize(
} }
// Remove all empty units. // Remove all empty units.
units.erase(std::remove_if(units.begin(), units.end(), base::EraseIf(units, [](const Unit& unit) { return unit.IsEmpty(); });
[](const Unit& unit) { return unit.IsEmpty(); }),
units.end());
// Sort |units| by RVA, then uniquefy. // Sort |units| by RVA, then uniquefy.
std::sort(units.begin(), units.end(), [](const Unit& a, const Unit& b) { std::sort(units.begin(), units.end(), [](const Unit& a, const Unit& b) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <limits> #include <limits>
#include "base/logging.h" #include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
namespace zucchini { namespace zucchini {
...@@ -30,9 +31,7 @@ void EnsembleMatcher::Trim() { ...@@ -30,9 +31,7 @@ void EnsembleMatcher::Trim() {
auto num_dex = std::count_if(matches_.begin(), matches_.end(), is_match_dex); auto num_dex = std::count_if(matches_.begin(), matches_.end(), is_match_dex);
if (num_dex > 1) { if (num_dex > 1) {
LOG(WARNING) << "Found " << num_dex << " DEX: Ignoring all."; LOG(WARNING) << "Found " << num_dex << " DEX: Ignoring all.";
matches_.erase( base::EraseIf(matches_, is_match_dex);
std::remove_if(matches_.begin(), matches_.end(), is_match_dex),
matches_.end());
} }
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/stl_util.h"
#include "components/zucchini/encoded_view.h" #include "components/zucchini/encoded_view.h"
#include "components/zucchini/patch_reader.h" #include "components/zucchini/patch_reader.h"
#include "components/zucchini/suffix_array.h" #include "components/zucchini/suffix_array.h"
...@@ -304,8 +305,7 @@ void OffsetMapper::ForwardProjectAll(std::vector<offset_t>* offsets) const { ...@@ -304,8 +305,7 @@ void OffsetMapper::ForwardProjectAll(std::vector<offset_t>* offsets) const {
src = kInvalidOffset; src = kInvalidOffset;
} }
} }
offsets->erase(std::remove(offsets->begin(), offsets->end(), kInvalidOffset), base::Erase(*offsets, kInvalidOffset);
offsets->end());
offsets->shrink_to_fit(); offsets->shrink_to_fit();
} }
...@@ -365,11 +365,9 @@ void OffsetMapper::PruneEquivalencesAndSortBySource( ...@@ -365,11 +365,9 @@ void OffsetMapper::PruneEquivalencesAndSortBySource(
} }
// Discard all equivalences with length == 0. // Discard all equivalences with length == 0.
equivalences->erase(std::remove_if(equivalences->begin(), equivalences->end(), base::EraseIf(*equivalences, [](const Equivalence& equivalence) {
[](const Equivalence& equivalence) { return equivalence.length == 0;
return equivalence.length == 0; });
}),
equivalences->end());
} }
/******** EquivalenceMap ********/ /******** EquivalenceMap ********/
...@@ -541,12 +539,10 @@ void EquivalenceMap::Prune( ...@@ -541,12 +539,10 @@ void EquivalenceMap::Prune(
} }
// Discard all candidates with similarity smaller than |min_similarity|. // Discard all candidates with similarity smaller than |min_similarity|.
candidates_.erase( base::EraseIf(candidates_,
std::remove_if(candidates_.begin(), candidates_.end(), [min_similarity](const EquivalenceCandidate& candidate) {
[min_similarity](const EquivalenceCandidate& candidate) { return candidate.similarity < min_similarity;
return candidate.similarity < min_similarity; });
}),
candidates_.end());
} }
} // namespace zucchini } // namespace zucchini
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment