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