0

Use base::ranges::transform() instead std::transform in //components and //content

1. Use base::ranges::transform() instead std::transform in //components and //content.

2. Simplify some code.

Bug: 1368812
Change-Id: If11aebc2a25e38b8f7398e05631e3266cbc283c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5151747
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1244128}
This commit is contained in:
Binoy Kumar Sutradhar
2024-01-08 17:40:38 +00:00
committed by Chromium LUCI CQ
parent bd606706e7
commit ed18e17887
3 changed files with 9 additions and 6 deletions
components
allocation_recorder
safe_search_api
content/public/test

@ -14,6 +14,7 @@
#include "base/debug/debugging_buildflags.h" #include "base/debug/debugging_buildflags.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/functional/callback.h" #include "base/functional/callback.h"
#include "base/ranges/algorithm.h"
#include "base/threading/platform_thread.h" #include "base/threading/platform_thread.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h" #include "build/build_config.h"
@ -120,8 +121,8 @@ void CrashpadIntegration::SetUp(const base::FilePath& crashpad_database_path) {
<< "Failed to read list of old pending reports. database='" << "Failed to read list of old pending reports. database='"
<< database_dir_ << '\''; << database_dir_ << '\'';
std::transform( base::ranges::transform(
std::begin(old_reports), std::end(old_reports), old_reports,
std::inserter(ids_of_old_reports_, std::end(ids_of_old_reports_)), std::inserter(ids_of_old_reports_, std::end(ids_of_old_reports_)),
[](const crashpad::CrashReportDatabase::Report& report) { [](const crashpad::CrashReportDatabase::Report& report) {
return report.uuid; return report.uuid;

@ -17,6 +17,7 @@
#include "base/functional/bind.h" #include "base/functional/bind.h"
#include "base/functional/callback.h" #include "base/functional/callback.h"
#include "base/memory/raw_ptr.h" #include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "components/safe_search_api/fake_url_checker_client.h" #include "components/safe_search_api/fake_url_checker_client.h"
@ -55,8 +56,8 @@ ClientClassification ToAPIClassification(Classification classification,
auto Recorded(const std::map<CacheAccessStatus, int>& expected) { auto Recorded(const std::map<CacheAccessStatus, int>& expected) {
std::vector<base::Bucket> buckets_array; std::vector<base::Bucket> buckets_array;
std::transform( base::ranges::transform(
expected.begin(), expected.end(), std::back_inserter(buckets_array), expected, std::back_inserter(buckets_array),
[](auto& entry) { return base::Bucket(entry.first, entry.second); }); [](auto& entry) { return base::Bucket(entry.first, entry.second); });
return base::BucketsInclude(buckets_array); return base::BucketsInclude(buckets_array);
} }

@ -20,6 +20,7 @@
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "base/process/kill.h" #include "base/process/kill.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/pattern.h" #include "base/strings/pattern.h"
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
@ -1836,8 +1837,8 @@ std::vector<RenderFrameHost*> CollectAllRenderFrameHosts(
std::vector<WebContents*> GetAllWebContents() { std::vector<WebContents*> GetAllWebContents() {
std::vector<WebContentsImpl*> all_wci = WebContentsImpl::GetAllWebContents(); std::vector<WebContentsImpl*> all_wci = WebContentsImpl::GetAllWebContents();
std::vector<WebContents*> all_wc; std::vector<WebContents*> all_wc;
std::transform(all_wci.cbegin(), all_wci.cend(), std::back_inserter(all_wc), base::ranges::transform(all_wci, std::back_inserter(all_wc),
[](WebContentsImpl* wc) { return wc; }); [](WebContentsImpl* wc) { return wc; });
return all_wc; return all_wc;
} }