Commit e43c9f5c authored by tripta.g's avatar tripta.g Committed by Commit Bot

Use ContainsValue() instead of std::find() in ui/android, ui/base and ui/views

BUG=561800

Review-Url: https://codereview.chromium.org/2930573005
Cr-Commit-Position: refs/heads/master@{#478558}
parent a40d8abd
......@@ -9,6 +9,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/containers/adapters.h"
#include "base/stl_util.h"
#include "cc/layers/layer.h"
#include "jni/ViewAndroidDelegate_jni.h"
#include "ui/android/event_forwarder.h"
......@@ -116,8 +117,7 @@ ScopedJavaLocalRef<jobject> ViewAndroid::GetEventForwarder() {
void ViewAndroid::AddChild(ViewAndroid* child) {
DCHECK(child);
DCHECK(std::find(children_.begin(), children_.end(), child) ==
children_.end());
DCHECK(!base::ContainsValue(children_, child));
DCHECK(!RootPathHasEventForwarder(this) || !SubtreeHasEventForwarder(child))
<< "Some view tree path will have more than one event forwarder "
"if the child is added.";
......
......@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/logging.h"
#include "base/stl_util.h"
#include "ui/base/accelerators/accelerator_manager_delegate.h"
namespace ui {
......@@ -28,7 +29,7 @@ void AcceleratorManager::Register(
for (const ui::Accelerator& accelerator : accelerators) {
AcceleratorTargetList& targets = accelerators_[accelerator].second;
DCHECK(std::find(targets.begin(), targets.end(), target) == targets.end())
DCHECK(!base::ContainsValue(targets, target))
<< "Registering the same target multiple times";
const bool is_first_target_for_accelerator = targets.empty();
......@@ -71,9 +72,7 @@ void AcceleratorManager::UnregisterAll(AcceleratorTarget* target) {
for (AcceleratorMap::iterator map_iter = accelerators_.begin();
map_iter != accelerators_.end();) {
AcceleratorTargetList* targets = &map_iter->second.second;
AcceleratorTargetList::iterator target_iter =
std::find(targets->begin(), targets->end(), target);
if (target_iter == targets->end()) {
if (!base::ContainsValue(*targets, target)) {
++map_iter;
} else {
auto tmp_iter = map_iter;
......
......@@ -4,7 +4,6 @@
#include "ui/base/clipboard/clipboard.h"
#include <algorithm>
#include <iterator>
#include <limits>
#include <memory>
......@@ -12,6 +11,7 @@
#include "base/debug/dump_without_crashing.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/size.h"
......@@ -159,9 +159,7 @@ base::PlatformThreadId Clipboard::GetAndValidateThreadID() {
// TODO(fdoray): Surround this block with #if DCHECK_IS_ON() and remove the
// DumpWithoutCrashing() call once https://crbug.com/662055 is resolved.
AllowedThreadsVector* allowed_threads = allowed_threads_.Pointer();
if (!allowed_threads->empty() &&
std::find(allowed_threads->begin(), allowed_threads->end(), id) ==
allowed_threads->end()) {
if (!allowed_threads->empty() && !base::ContainsValue(*allowed_threads, id)) {
NOTREACHED();
base::debug::DumpWithoutCrashing();
}
......
......@@ -9,6 +9,7 @@
#include <memory>
#include "base/macros.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/event.h"
......@@ -249,8 +250,7 @@ TEST_F(CharacterComposerTest, MainTableIsCorrectlyOrdered) {
EXPECT_LT(previous_key, key) << index;
previous_key = key;
// Verify that the internal link is valid.
const auto it = std::find(subtrees.begin(), subtrees.end(), value);
EXPECT_FALSE(subtrees.end() == it) << index;
EXPECT_TRUE(base::ContainsValue(subtrees, value)) << index;
index += 2;
}
// Check the leaf subtable.
......
......@@ -8,6 +8,7 @@
#include <valarray>
#include "base/logging.h"
#include "base/stl_util.h"
namespace ui {
......@@ -67,8 +68,7 @@ void ListSelectionModel::SetSelectedIndex(int index) {
}
bool ListSelectionModel::IsSelected(int index) const {
return std::find(selected_indices_.begin(), selected_indices_.end(), index) !=
selected_indices_.end();
return base::ContainsValue(selected_indices_, index);
}
void ListSelectionModel::AddIndexToSelection(int index) {
......
......@@ -686,9 +686,7 @@ ScaleFactor ResourceBundle::GetMaxScaleFactor() const {
bool ResourceBundle::IsScaleFactorSupported(ScaleFactor scale_factor) {
const std::vector<ScaleFactor>& supported_scale_factors =
ui::GetSupportedScaleFactors();
return std::find(supported_scale_factors.begin(),
supported_scale_factors.end(),
scale_factor) != supported_scale_factors.end();
return base::ContainsValue(supported_scale_factors, scale_factor);
}
ResourceBundle::ResourceBundle(Delegate* delegate)
......
......@@ -6,11 +6,11 @@
#include <stdint.h>
#include <algorithm>
#include <set>
#include "base/i18n/icu_string_conversions.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
......@@ -53,9 +53,7 @@ void GetAtomIntersection(const std::vector< ::Atom>& desired,
std::vector< ::Atom>* output) {
for (std::vector< ::Atom>::const_iterator it = desired.begin();
it != desired.end(); ++it) {
std::vector< ::Atom>::const_iterator jt =
std::find(offered.begin(), offered.end(), *it);
if (jt != offered.end())
if (base::ContainsValue(offered, *it))
output->push_back(*it);
}
}
......
......@@ -1196,10 +1196,7 @@ bool IsX11WindowFullScreen(XID window) {
if (GetAtomArrayProperty(window,
"_NET_WM_STATE",
&atom_properties)) {
return std::find(atom_properties.begin(),
atom_properties.end(),
fullscreen_atom) !=
atom_properties.end();
return base::ContainsValue(atom_properties, fullscreen_atom);
}
}
......@@ -1230,8 +1227,7 @@ bool WmSupportsHint(XAtom atom) {
return false;
}
return std::find(supported_atoms.begin(), supported_atoms.end(), atom) !=
supported_atoms.end();
return base::ContainsValue(supported_atoms, atom);
}
XRefcountedMemory::XRefcountedMemory(unsigned char* x11_data, size_t length)
......
......@@ -4,11 +4,10 @@
#include "ui/views/layout/grid_layout.h"
#include <algorithm>
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "ui/views/border.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/view.h"
......@@ -485,9 +484,7 @@ void ColumnSet::AccumulateMasterColumns() {
DCHECK(master_columns_.empty());
for (const auto& column : columns_) {
Column* master_column = column->GetLastMasterColumn();
if (master_column &&
std::find(master_columns_.begin(), master_columns_.end(),
master_column) == master_columns_.end()) {
if (master_column && !base::ContainsValue(master_columns_, master_column)) {
master_columns_.push_back(master_column);
}
// At this point, GetLastMasterColumn may not == master_column
......
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