[gin] Use base::Contains() instead of std::find() in //gin
Use base::Contains() instead of std::find() where appropriate in //gin. Bug: 561800 Change-Id: Id2b16204b6e086b35f77a504505cd551addf9e05 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4780835 Commit-Queue: Ho Cheung <uioptt24@gmail.com> Reviewed-by: Kentaro Hara <haraken@chromium.org> Cr-Commit-Position: refs/heads/main@{#1184086}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
a2270a38ec
commit
008e3120d8
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
#include "base/task/thread_pool/thread_pool_instance.h"
|
||||
#include "base/trace_event/process_memory_dump.h"
|
||||
@ -53,13 +54,13 @@ TEST_F(V8MemoryDumpProviderTest, DumpStatistics) {
|
||||
bool did_dump_objects_stats = false;
|
||||
for (const auto& name_dump : allocator_dumps) {
|
||||
const std::string& name = name_dump.first;
|
||||
if (name.find("v8/main") != std::string::npos) {
|
||||
if (base::Contains(name, "v8/main")) {
|
||||
did_dump_isolate_stats = true;
|
||||
}
|
||||
if (name.find("v8/main/heap") != std::string::npos) {
|
||||
if (base::Contains(name, "v8/main/heap")) {
|
||||
did_dump_space_stats = true;
|
||||
}
|
||||
if (name.find("v8/main/heap_objects") != std::string::npos) {
|
||||
if (base::Contains(name, "v8/main/heap_objects")) {
|
||||
did_dump_objects_stats = true;
|
||||
}
|
||||
}
|
||||
@ -82,7 +83,7 @@ TEST_F(V8MemoryDumpProviderTest, DumpGlobalHandlesSize) {
|
||||
bool did_dump_global_handles = false;
|
||||
for (const auto& name_dump : allocator_dumps) {
|
||||
const std::string& name = name_dump.first;
|
||||
if (name.find("v8/main/global_handles") != std::string::npos) {
|
||||
if (base::Contains(name, "v8/main/global_handles")) {
|
||||
did_dump_global_handles = true;
|
||||
}
|
||||
}
|
||||
@ -104,10 +105,10 @@ TEST_F(V8MemoryDumpProviderTest, DumpContextStatistics) {
|
||||
bool did_dump_native_contexts = false;
|
||||
for (const auto& name_dump : allocator_dumps) {
|
||||
const std::string& name = name_dump.first;
|
||||
if (name.find("main/contexts/detached_context") != std::string::npos) {
|
||||
if (base::Contains(name, "main/contexts/detached_context")) {
|
||||
did_dump_detached_contexts = true;
|
||||
}
|
||||
if (name.find("main/contexts/native_context") != std::string::npos) {
|
||||
if (base::Contains(name, "main/contexts/native_context")) {
|
||||
did_dump_native_contexts = true;
|
||||
}
|
||||
}
|
||||
@ -130,12 +131,10 @@ TEST_F(V8MemoryDumpProviderWorkerTest, DumpContextStatistics) {
|
||||
bool did_dump_native_contexts = false;
|
||||
for (const auto& name_dump : allocator_dumps) {
|
||||
const std::string& name = name_dump.first;
|
||||
if (name.find("workers/contexts/detached_context/isolate_0x") !=
|
||||
std::string::npos) {
|
||||
if (base::Contains(name, "workers/contexts/detached_context/isolate_0x")) {
|
||||
did_dump_detached_contexts = true;
|
||||
}
|
||||
if (name.find("workers/contexts/native_context/isolate_0x") !=
|
||||
std::string::npos) {
|
||||
if (base::Contains(name, "workers/contexts/native_context/isolate_0x")) {
|
||||
did_dump_native_contexts = true;
|
||||
}
|
||||
}
|
||||
@ -167,16 +166,16 @@ TEST_F(V8MemoryDumpProviderTest, DumpCodeStatistics) {
|
||||
|
||||
for (const auto& name_dump : allocator_dumps) {
|
||||
const std::string& name = name_dump.first;
|
||||
if (name.find("code_stats") != std::string::npos) {
|
||||
if (base::Contains(name, "code_stats")) {
|
||||
for (const base::trace_event::MemoryAllocatorDump::Entry& entry :
|
||||
name_dump.second->entries()) {
|
||||
if (entry.name == "bytecode_and_metadata_size") {
|
||||
if (base::Contains(entry.name, "bytecode_and_metadata_size")) {
|
||||
did_dump_bytecode_size = true;
|
||||
} else if (entry.name == "code_and_metadata_size") {
|
||||
} else if (base::Contains(entry.name, "code_and_metadata_size")) {
|
||||
did_dump_code_size = true;
|
||||
} else if (entry.name == "external_script_source_size") {
|
||||
} else if (base::Contains(entry.name, "external_script_source_size")) {
|
||||
did_dump_external_scripts_size = true;
|
||||
} else if (entry.name == "cpu_profiler_metadata_size") {
|
||||
} else if (base::Contains(entry.name, "cpu_profiler_metadata_size")) {
|
||||
did_dump_cpu_profiler_metadata_size = true;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/trace_event/process_memory_dump.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "gin/test/v8_test.h"
|
||||
@ -30,10 +31,10 @@ TEST_F(V8SharedMemoryDumpProviderTest, DumpStatistics) {
|
||||
bool did_dump_read_only_space = false;
|
||||
for (const auto& name_dump : allocator_dumps) {
|
||||
const std::string& name = name_dump.first;
|
||||
if (name.find("v8/shared") != std::string::npos) {
|
||||
if (base::Contains(name, "v8/shared")) {
|
||||
did_dump_shared_memory_stats = true;
|
||||
}
|
||||
if (name.find("v8/shared/read_only_space") != std::string::npos) {
|
||||
if (base::Contains(name, "v8/shared/read_only_space")) {
|
||||
did_dump_read_only_space = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user