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