Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
src: use starts_with instead of rfind/find
  • Loading branch information
tniessen committed Jan 18, 2026
commit a4324c68a7fc7b47d7d80ff07ad9482a980daa38
2 changes: 1 addition & 1 deletion src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<ada::url_aggregator>(normalized_string);
auto file_path = url::FileURLToPath(env, *out);
if (!file_path.has_value()) {
Expand Down
Loading