From a4324c68a7fc7b47d7d80ff07ad9482a980daa38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sun, 18 Jan 2026 12:30:10 +0100 Subject: [PATCH] src: use starts_with instead of rfind/find --- src/node_builtins.cc | 2 +- src/path.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node_builtins.cc b/src/node_builtins.cc index 2a77bf6d7a4715..db83c46c81f767 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -169,7 +169,7 @@ BuiltinLoader::BuiltinCategories BuiltinLoader::GetBuiltinCategories() const { if (prefix.length() > id.length()) { continue; } - if (id.find(prefix) == 0 && + if (id.starts_with(prefix) && builtin_categories.can_be_required.count(id) == 0) { builtin_categories.cannot_be_required.emplace(id); } diff --git a/src/path.cc b/src/path.cc index 582786a77ce6f4..f4b8d4577bd1e6 100644 --- a/src/path.cc +++ b/src/path.cc @@ -341,7 +341,7 @@ void FromNamespacedPath(std::string* path) { // Check if a path looks like an absolute path or file URL. bool IsAbsoluteFilePath(std::string_view path) { - if (path.rfind("file://", 0) == 0) { + if (path.starts_with("file://")) { return true; } #ifdef _WIN32 @@ -357,7 +357,7 @@ bool IsAbsoluteFilePath(std::string_view path) { std::string NormalizeFileURLOrPath(Environment* env, std::string_view path) { std::string normalized_string(path); constexpr std::string_view file_scheme = "file://"; - if (normalized_string.rfind(file_scheme, 0) == 0) { + if (normalized_string.starts_with(file_scheme)) { auto out = ada::parse(normalized_string); auto file_path = url::FileURLToPath(env, *out); if (!file_path.has_value()) {