Skip to content

Commit

Permalink
Changed std::find() to ContainsValue()/ContainsKey() in src/base/*
Browse files Browse the repository at this point in the history
Bug: 561800

Change-Id: I1d92457335d4ee13b7289ce3601160083702e367
Reviewed-on: https://chromium-review.googlesource.com/919021
Commit-Queue: srirama chandra sekhar <srirama.m@samsung.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537214}
  • Loading branch information
Ganesh Borle authored and Commit Bot committed Feb 16, 2018
1 parent ce3464b commit 36fadc6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ Fu Junwei <junwei.fu@intel.com>
Gaetano Mendola <mendola@gmail.com>
Gajendra N <gajendra.n@samsung.com>
Gajendra Singh <wxjg68@motorola.com>
Ganesh Borle <ganesh.borle@samsung.com>
Gao Chun <chun.gao@intel.com>
Gao Chun <gaochun.dev@gmail.com>
George Joseph <kottackal.george@gmail.com>
Expand Down
4 changes: 2 additions & 2 deletions base/mac/objc_release_properties_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include "base/mac/objc_release_properties.h"
#include "base/stl_util.h"

#import "base/mac/scoped_nsautorelease_pool.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand Down Expand Up @@ -216,8 +217,7 @@ + (BOOL)resolveInstanceMethod:(SEL)sel {
@selector(baseCvcDynamic), @selector(derivedCvcDynamic),
@selector(protoCvcDynamic),
};
if (std::find(dynamicMethods.begin(), dynamicMethods.end(), sel) ==
dynamicMethods.end()) {
if (!base::ContainsValue(dynamicMethods, sel)) {
return NO;
}
id (*imp)() = []() -> id { return nil; };
Expand Down
3 changes: 2 additions & 1 deletion base/task_scheduler/scheduler_worker_stack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <algorithm>

#include "base/logging.h"
#include "base/stl_util.h"

namespace base {
namespace internal {
Expand Down Expand Up @@ -35,7 +36,7 @@ SchedulerWorker* SchedulerWorkerStack::Peek() const {
}

bool SchedulerWorkerStack::Contains(const SchedulerWorker* worker) const {
return std::find(stack_.begin(), stack_.end(), worker) != stack_.end();
return ContainsValue(stack_, worker);
}

void SchedulerWorkerStack::Remove(const SchedulerWorker* worker) {
Expand Down
4 changes: 1 addition & 3 deletions base/trace_event/trace_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1217,9 +1217,7 @@ TraceEventHandle TraceLog::AddTraceEventWithThreadIdAndTimestamp(
std::vector<StringPiece> existing_names = base::SplitStringPiece(
existing_name->second, ",", base::KEEP_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);
bool found = std::find(existing_names.begin(), existing_names.end(),
new_name) != existing_names.end();
if (!found) {
if (!ContainsValue(existing_names, new_name)) {
if (!existing_names.empty())
existing_name->second.push_back(',');
existing_name->second.append(new_name);
Expand Down
3 changes: 2 additions & 1 deletion base/values.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/memory_usage_estimator.h"
Expand Down Expand Up @@ -1338,7 +1339,7 @@ void ListValue::AppendStrings(const std::vector<string16>& in_values) {

bool ListValue::AppendIfNotPresent(std::unique_ptr<Value> in_value) {
DCHECK(in_value);
if (std::find(list_.begin(), list_.end(), *in_value) != list_.end())
if (ContainsValue(list_, *in_value))
return false;

list_.push_back(std::move(*in_value));
Expand Down

0 comments on commit 36fadc6

Please sign in to comment.