[cleanup] Replace base::ranges with std::ranges: sql/
Done entirely with `git grep` and `sed` + `git cl format`, no hand-editing. Bug: 386918226 Change-Id: Ic4bae3c955936455ce0112a7e5d4efe806f5b9b9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6196286 Commit-Queue: Etienne Bergeron <etienneb@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Etienne Bergeron <etienneb@chromium.org> Auto-Submit: Peter Kasting <pkasting@chromium.org> Commit-Queue: Peter Kasting <pkasting@chromium.org> Cr-Commit-Position: refs/heads/main@{#1411795}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
413ebc5984
commit
3f01b691ee
@ -14,6 +14,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@ -39,7 +40,6 @@
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/notimplemented.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "base/strings/cstring_view.h"
|
||||
#include "base/strings/strcat.h"
|
||||
@ -180,8 +180,8 @@ bool ValidAttachmentPoint(std::string_view attachment_point) {
|
||||
// Chrome's constraint is easy to remember, and sufficient for the few
|
||||
// existing use cases. ATTACH is a discouraged feature, so no new use cases
|
||||
// are expected.
|
||||
return base::ranges::all_of(attachment_point,
|
||||
[](char ch) { return base::IsAsciiLower(ch); });
|
||||
return std::ranges::all_of(attachment_point,
|
||||
[](char ch) { return base::IsAsciiLower(ch); });
|
||||
}
|
||||
|
||||
std::string AsUTF8ForSQL(const base::FilePath& path) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@ -33,7 +34,6 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "base/strings/cstring_view.h"
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <fuzzer/FuzzedDataProvider.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <ios>
|
||||
@ -34,7 +35,6 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/cstring_view.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
@ -75,7 +75,7 @@ std::optional<base::CommandLine> GetCommandLine() {
|
||||
additional_args, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
std::vector<std::wstring> wargv(argv.size());
|
||||
base::ranges::transform(
|
||||
std::ranges::transform(
|
||||
argv.begin(), argv.end(), wargv.begin(),
|
||||
[](std::string str) { return std::wstring(str.begin(), str.end()); });
|
||||
return base::CommandLine::FromArgvWithoutProgram(wargv);
|
||||
@ -259,10 +259,10 @@ DEFINE_PROTO_FUZZER(const sql_fuzzers::RecoveryFuzzerTestCase& fuzzer_input) {
|
||||
//
|
||||
// TODO: A slight improvement would be to filter out individual "ATTACH
|
||||
// DATABASE" queries rather than throwing away the whole test case.
|
||||
if (base::ranges::any_of(fuzzer_input.queries().extra_queries(),
|
||||
&sql_query_grammar::SQLQuery::has_attach_db) ||
|
||||
base::ranges::any_of(fuzzer_input.queries_after_open().extra_queries(),
|
||||
&sql_query_grammar::SQLQuery::has_attach_db)) {
|
||||
if (std::ranges::any_of(fuzzer_input.queries().extra_queries(),
|
||||
&sql_query_grammar::SQLQuery::has_attach_db) ||
|
||||
std::ranges::any_of(fuzzer_input.queries_after_open().extra_queries(),
|
||||
&sql_query_grammar::SQLQuery::has_attach_db)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
@ -24,7 +25,6 @@
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/test/bind.h"
|
||||
@ -237,7 +237,7 @@ TEST_P(SqlRecoveryTest, RecoverCorruptTable) {
|
||||
ASSERT_EQ(db_.page_size(), kDbPageSize)
|
||||
<< "Page overflow relies on specific size";
|
||||
large_buffer.resize(kDbPageSize * 2);
|
||||
base::ranges::fill(large_buffer, '8');
|
||||
std::ranges::fill(large_buffer, '8');
|
||||
sql::Statement insert(db_.GetUniqueStatement(
|
||||
"INSERT INTO rows(indexed,unindexed,filler) VALUES(8,8,?)"));
|
||||
insert.BindBlob(0, large_buffer);
|
||||
@ -477,7 +477,7 @@ void TestRecoverDatabase(Database& db,
|
||||
// Save aside a copy of the original schema, verifying that it has the created
|
||||
// items plus the sqlite_sequence table.
|
||||
const std::string original_schema = GetSchema(&db);
|
||||
ASSERT_EQ(with_meta ? 6 : 4, base::ranges::count(original_schema, '\n'))
|
||||
ASSERT_EQ(with_meta ? 6 : 4, std::ranges::count(original_schema, '\n'))
|
||||
<< original_schema;
|
||||
|
||||
static constexpr char kTable1Sql[] = "SELECT * FROM table1 ORDER BY 1";
|
||||
@ -659,7 +659,7 @@ TEST_P(SqlRecoveryTest, RecoverDatabaseWithView) {
|
||||
// Save aside a copy of the original schema, verifying that it has the created
|
||||
// items plus the sqlite_sequence table.
|
||||
const std::string original_schema = GetSchema(&db);
|
||||
ASSERT_EQ(4, base::ranges::count(original_schema, '\n')) << original_schema;
|
||||
ASSERT_EQ(4, std::ranges::count(original_schema, '\n')) << original_schema;
|
||||
|
||||
// Database handle is valid before recovery, poisoned after.
|
||||
static constexpr char kTrivialSql[] = "SELECT COUNT(*) FROM sqlite_schema";
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "sql/sqlite_result_code.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <ostream> // Needed to compile CHECK() with operator <<.
|
||||
#include <ranges>
|
||||
@ -16,7 +17,6 @@
|
||||
#include "base/dcheck_is_on.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/metrics/histogram_functions.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "sql/sqlite_result_code_values.h"
|
||||
#include "third_party/sqlite/sqlite3.h"
|
||||
|
||||
@ -313,7 +313,7 @@ file lock requests"
|
||||
// Returns an entry in kResultCodeMapping or kUnknownResultCodeMappingEntry.
|
||||
// CHECKs if the `sqlite_result_code` is not in the mapping table.
|
||||
SqliteResultCodeMappingEntry FindResultCode(int sqlite_result_code) {
|
||||
const auto* mapping_it = base::ranges::find_if(
|
||||
const auto* mapping_it = std::ranges::find_if(
|
||||
kResultCodeMapping,
|
||||
[&sqlite_result_code](SqliteResultCodeMappingEntry rhs) {
|
||||
return sqlite_result_code == rhs.result_code;
|
||||
@ -415,7 +415,7 @@ std::ostream& operator<<(std::ostream& os, SqliteErrorCode sqlite_error_code) {
|
||||
|
||||
void CheckSqliteLoggedResultCodeForTesting() {
|
||||
// Ensure that error codes are alphabetical.
|
||||
const auto* unordered_it = base::ranges::adjacent_find(
|
||||
const auto* unordered_it = std::ranges::adjacent_find(
|
||||
kResultCodeMapping,
|
||||
[](SqliteResultCodeMappingEntry lhs, SqliteResultCodeMappingEntry rhs) {
|
||||
return lhs.result_code >= rhs.result_code;
|
||||
|
Reference in New Issue
Block a user