Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: components/password_manager/core/browser/credential_manager_pending_request_task.cc

Issue 2774653006: Refactor Password Manager to use base::EraseIf (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/password_manager/core/browser/form_fetcher_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/credential_manager_pending_request_task.cc
diff --git a/components/password_manager/core/browser/credential_manager_pending_request_task.cc b/components/password_manager/core/browser/credential_manager_pending_request_task.cc
index 6600bd4dc75827f1a70c6c19e211552aa4338dbe..ae1279ab3402dc1477e2263d2fec1016d974e1f5 100644
--- a/components/password_manager/core/browser/credential_manager_pending_request_task.cc
+++ b/components/password_manager/core/browser/credential_manager_pending_request_task.cc
@@ -11,6 +11,7 @@
#include "base/memory/ptr_util.h"
#include "base/metrics/user_metrics.h"
+#include "base/stl_util.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/affiliated_match_helper.h"
#include "components/password_manager/core/browser/password_bubble_experiment.h"
@@ -95,15 +96,14 @@ void FilterDuplicatesAndEmptyUsername(
bool* has_empty_username,
bool* has_duplicates) {
// Remove empty usernames from the list.
- auto begin_empty =
- std::remove_if(forms->begin(), forms->end(),
- [](const std::unique_ptr<autofill::PasswordForm>& form) {
- return form->username_value.empty();
- });
- *has_empty_username = (begin_empty != forms->end());
- forms->erase(begin_empty, forms->end());
+ size_t size_before = forms->size();
+ base::EraseIf(*forms,
+ [](const std::unique_ptr<autofill::PasswordForm>& form) {
+ return form->username_value.empty();
+ });
+ *has_empty_username = (size_before != forms->size());
- const size_t size_before = forms->size();
+ size_before = forms->size();
FilterDuplicates(forms);
*has_duplicates = (size_before != forms->size());
}
« no previous file with comments | « no previous file | components/password_manager/core/browser/form_fetcher_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698