Commit 2e9a253d authored by Hwanseung Lee's avatar Hwanseung Lee Committed by Commit Bot

Use ContainsValue() instead of std::find() at components/sync*

replace std::find() with base::containsValue()
at components/sync*

Bug: 561800
Change-Id: I450fe0c1d0e59244647bcdb23e2b6e2b29571dbc
Reviewed-on: https://chromium-review.googlesource.com/1102439Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Commit-Queue: Hwanseung Lee <hs1217.lee@samsung.com>
Cr-Commit-Position: refs/heads/master@{#568359}
parent 54e6e82a
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <string> #include <string>
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "components/sync/engine_impl/cycle/directory_type_debug_info_emitter.h" #include "components/sync/engine_impl/cycle/directory_type_debug_info_emitter.h"
#include "components/sync/syncable/entry.h" #include "components/sync/syncable/entry.h"
#include "components/sync/syncable/mutable_entry.h" #include "components/sync/syncable/mutable_entry.h"
...@@ -100,10 +101,11 @@ class DirectoryCommitContributionTest : public ::testing::Test { ...@@ -100,10 +101,11 @@ class DirectoryCommitContributionTest : public ::testing::Test {
// specified type. // specified type.
TEST_F(DirectoryCommitContributionTest, GatherByTypes) { TEST_F(DirectoryCommitContributionTest, GatherByTypes) {
int64_t pref1; int64_t pref1;
int64_t pref2;
{ {
syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir()); syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir());
pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1"); pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1");
CreateUnsyncedItem(&trans, PREFERENCES, "pref2"); pref2 = CreateUnsyncedItem(&trans, PREFERENCES, "pref2");
CreateUnsyncedItem(&trans, EXTENSIONS, "extension1"); CreateUnsyncedItem(&trans, EXTENSIONS, "extension1");
} }
...@@ -112,11 +114,8 @@ TEST_F(DirectoryCommitContributionTest, GatherByTypes) { ...@@ -112,11 +114,8 @@ TEST_F(DirectoryCommitContributionTest, GatherByTypes) {
DirectoryCommitContribution::Build(dir(), PREFERENCES, 5, &emitter)); DirectoryCommitContribution::Build(dir(), PREFERENCES, 5, &emitter));
ASSERT_EQ(2U, cc->GetNumEntries()); ASSERT_EQ(2U, cc->GetNumEntries());
const std::vector<int64_t>& metahandles = cc->metahandles_; EXPECT_TRUE(base::ContainsValue(cc->metahandles_, pref1));
EXPECT_TRUE(std::find(metahandles.begin(), metahandles.end(), pref1) != EXPECT_TRUE(base::ContainsValue(cc->metahandles_, pref2));
metahandles.end());
EXPECT_TRUE(std::find(metahandles.begin(), metahandles.end(), pref1) !=
metahandles.end());
cc->CleanUp(); cc->CleanUp();
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <set> #include <set>
#include "base/macros.h" #include "base/macros.h"
#include "base/stl_util.h"
#include "components/sync/base/cryptographer.h" #include "components/sync/base/cryptographer.h"
#include "components/sync/engine_impl/syncer_util.h" #include "components/sync/engine_impl/syncer_util.h"
#include "components/sync/syncable/entry.h" #include "components/sync/syncable/entry.h"
...@@ -276,8 +277,7 @@ void Traversal::AddDeletedParents(const std::set<int64_t>& ready_unsynced_set, ...@@ -276,8 +277,7 @@ void Traversal::AddDeletedParents(const std::set<int64_t>& ready_unsynced_set,
// We're not interested in non-deleted parents. // We're not interested in non-deleted parents.
break; break;
} }
if (std::find(traversed.begin(), traversed.end(), handle) != if (base::ContainsValue(traversed, handle)) {
traversed.end()) {
// We've already added this parent (and therefore all of its parents). // We've already added this parent (and therefore all of its parents).
// We can return early. // We can return early.
break; break;
...@@ -365,8 +365,7 @@ void Traversal::AddDeletes(const std::set<int64_t>& ready_unsynced_set) { ...@@ -365,8 +365,7 @@ void Traversal::AddDeletes(const std::set<int64_t>& ready_unsynced_set) {
if (HaveItem(handle)) if (HaveItem(handle))
continue; continue;
if (std::find(deletion_list.begin(), deletion_list.end(), handle) != if (base::ContainsValue(deletion_list, handle)) {
deletion_list.end()) {
continue; continue;
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "components/prefs/persistent_pref_store.h" #include "components/prefs/persistent_pref_store.h"
...@@ -292,7 +293,7 @@ std::unique_ptr<base::Value> PrefModelAssociator::MergeListValues( ...@@ -292,7 +293,7 @@ std::unique_ptr<base::Value> PrefModelAssociator::MergeListValues(
base::Value result = to_value.Clone(); base::Value result = to_value.Clone();
base::Value::ListStorage& list = result.GetList(); base::Value::ListStorage& list = result.GetList();
for (const auto& value : from_value.GetList()) { for (const auto& value : from_value.GetList()) {
if (std::find(list.begin(), list.end(), value) == list.end()) if (!base::ContainsValue(list, value))
list.emplace_back(value.Clone()); list.emplace_back(value.Clone());
} }
......
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