Skip to content

Commit

Permalink
Change std::find() to use base:: functions: device/
Browse files Browse the repository at this point in the history
Simplifies code slightly.

Bug: 1368812
Change-Id: Ia6013b0dbf9778a4c786b3cdebe474813b896541
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3927756
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Commit-Queue: Sonny Sasaka <sonnysasaka@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1052761}
  • Loading branch information
pkasting authored and Chromium LUCI CQ committed Sep 29, 2022
1 parent 2c062ca commit d49c264
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions device/bluetooth/dbus/fake_bluetooth_battery_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/observer_list.h"
#include "base/ranges/algorithm.h"
#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
#include "third_party/cros_system_api/dbus/service_constants.h"

Expand Down Expand Up @@ -78,8 +79,7 @@ void FakeBluetoothBatteryClient::RemoveBattery(const dbus::ObjectPath& path) {
DCHECK(base::Contains(battery_list_, path));

properties_map_.erase(path);
battery_list_.erase(
std::find(battery_list_.begin(), battery_list_.end(), path));
battery_list_.erase(base::ranges::find(battery_list_, path));

for (auto& observer : observers_)
observer.BatteryRemoved(path);
Expand Down
5 changes: 2 additions & 3 deletions device/bluetooth/dbus/fake_bluetooth_device_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <sys/types.h>
#include <unistd.h>

#include <algorithm>
#include <memory>
#include <string>
#include <utility>
Expand All @@ -24,6 +23,7 @@
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "base/rand_util.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
Expand Down Expand Up @@ -1150,8 +1150,7 @@ base::Value FakeBluetoothDeviceClient::GetBluetoothDevicesAsDictionaries()
void FakeBluetoothDeviceClient::RemoveDevice(
const dbus::ObjectPath& adapter_path,
const dbus::ObjectPath& device_path) {
auto listiter =
std::find(device_list_.begin(), device_list_.end(), device_path);
auto listiter = base::ranges::find(device_list_, device_path);
if (listiter == device_list_.end())
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "base/location.h"
#include "base/logging.h"
#include "base/ranges/algorithm.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "dbus/bus.h"
Expand Down Expand Up @@ -85,8 +86,7 @@ void FakeBluetoothLEAdvertisingManagerClient::UnregisterAdvertisement(

auto service_iter = service_provider_map_.find(advertisement_object_path);
auto reg_iter =
std::find(currently_registered_.begin(), currently_registered_.end(),
advertisement_object_path);
base::ranges::find(currently_registered_, advertisement_object_path);

if (service_iter == service_provider_map_.end()) {
std::move(error_callback)
Expand Down

0 comments on commit d49c264

Please sign in to comment.