Skip to content

Commit 805673a

Browse files
authored
src: use starts_with instead of rfind/find
PR-URL: #61426 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent f5b312b commit 805673a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/node_builtins.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ BuiltinLoader::BuiltinCategories BuiltinLoader::GetBuiltinCategories() const {
169169
if (prefix.length() > id.length()) {
170170
continue;
171171
}
172-
if (id.find(prefix) == 0 &&
172+
if (id.starts_with(prefix) &&
173173
builtin_categories.can_be_required.count(id) == 0) {
174174
builtin_categories.cannot_be_required.emplace(id);
175175
}

src/path.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ void FromNamespacedPath(std::string* path) {
341341

342342
// Check if a path looks like an absolute path or file URL.
343343
bool IsAbsoluteFilePath(std::string_view path) {
344-
if (path.rfind("file://", 0) == 0) {
344+
if (path.starts_with("file://")) {
345345
return true;
346346
}
347347
#ifdef _WIN32
@@ -357,7 +357,7 @@ bool IsAbsoluteFilePath(std::string_view path) {
357357
std::string NormalizeFileURLOrPath(Environment* env, std::string_view path) {
358358
std::string normalized_string(path);
359359
constexpr std::string_view file_scheme = "file://";
360-
if (normalized_string.rfind(file_scheme, 0) == 0) {
360+
if (normalized_string.starts_with(file_scheme)) {
361361
auto out = ada::parse<ada::url_aggregator>(normalized_string);
362362
auto file_path = url::FileURLToPath(env, *out);
363363
if (!file_path.has_value()) {

0 commit comments

Comments
 (0)