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

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

Issue 2565173002: Remove ScopedVector from PasswordStoreX (Closed)
Patch Set: Fix libsecret unittest compilation Created 4 years 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
Index: components/password_manager/core/browser/password_manager_util.cc
diff --git a/components/password_manager/core/browser/password_manager_util.cc b/components/password_manager/core/browser/password_manager_util.cc
index 6383418df27aec8e0804872bf9f804917d106510..d2fa75e2ac603b280a3a8539cf9f4d76e658e2f9 100644
--- a/components/password_manager/core/browser/password_manager_util.cc
+++ b/components/password_manager/core/browser/password_manager_util.cc
@@ -26,8 +26,8 @@ password_manager::PasswordSyncState GetPasswordSyncState(
}
void FindDuplicates(
- ScopedVector<autofill::PasswordForm>* forms,
- ScopedVector<autofill::PasswordForm>* duplicates,
+ std::vector<std::unique_ptr<autofill::PasswordForm>>* forms,
+ std::vector<std::unique_ptr<autofill::PasswordForm>>* duplicates,
std::vector<std::vector<autofill::PasswordForm*>>* tag_groups) {
if (forms->empty())
return;
@@ -36,27 +36,26 @@ void FindDuplicates(
// duplicates. Therefore, the caller should try to preserve it.
std::stable_sort(forms->begin(), forms->end(), autofill::LessThanUniqueKey());
- ScopedVector<autofill::PasswordForm> unique_forms;
- unique_forms.push_back(forms->front());
- forms->front() = nullptr;
+ std::vector<std::unique_ptr<autofill::PasswordForm>> unique_forms;
+ unique_forms.push_back(std::move(forms->front()));
if (tag_groups) {
tag_groups->clear();
tag_groups->push_back(std::vector<autofill::PasswordForm*>());
- tag_groups->front().push_back(unique_forms.front());
+ tag_groups->front().push_back(unique_forms.front().get());
}
for (auto it = forms->begin() + 1; it != forms->end(); ++it) {
- if (ArePasswordFormUniqueKeyEqual(**it, *unique_forms.back())) {
- duplicates->push_back(*it);
+ if (autofill::ArePasswordFormUniqueKeyEqual(**it, *unique_forms.back())) {
vabr (Chromium) 2016/12/12 18:34:26 Based on your explanation, I'm dropping the unnece
if (tag_groups)
- tag_groups->back().push_back(*it);
+ tag_groups->back().push_back(it->get());
+ duplicates->push_back(std::move(*it));
} else {
- unique_forms.push_back(*it);
if (tag_groups)
- tag_groups->push_back(std::vector<autofill::PasswordForm*>(1, *it));
+ tag_groups->push_back(
+ std::vector<autofill::PasswordForm*>(1, it->get()));
+ unique_forms.push_back(std::move(*it));
}
*it = nullptr;
vasilii 2016/12/12 18:10:57 not needed.
vabr (Chromium) 2016/12/12 18:34:26 Well spotted, thanks!
}
- forms->weak_clear();
forms->swap(unique_forms);
}

Powered by Google App Engine
This is Rietveld 408576698