diff --git a/src/node_options.cc b/src/node_options.cc index 2ca6652538b30b..3cc091da30bd5a 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -52,19 +52,19 @@ void DebugOptions::CheckOptions(std::vector* errors, "`node --inspect-brk` instead."); } - using std::string_view_literals::operator""sv; - const std::vector destinations = - SplitString(inspect_publish_uid_string, ","sv); + using std::operator""sv; + auto entries = std::views::split(inspect_publish_uid_string, ","sv); inspect_publish_uid.console = false; inspect_publish_uid.http = false; - for (const std::string_view destination : destinations) { + for (const auto& entry : entries) { + std::string_view destination(entry.data(), entry.size()); if (destination == "stderr"sv) { inspect_publish_uid.console = true; } else if (destination == "http"sv) { inspect_publish_uid.http = true; } else { - errors->push_back("--inspect-publish-uid destination can be " - "stderr or http"); + errors->emplace_back("--inspect-publish-uid destination can be " + "stderr or http"); } } } diff --git a/src/node_v8_platform-inl.h b/src/node_v8_platform-inl.h index 2b06dc982e4a91..fc0922035aac07 100644 --- a/src/node_v8_platform-inl.h +++ b/src/node_v8_platform-inl.h @@ -128,19 +128,19 @@ struct V8Platform { inline void StartTracingAgent() { constexpr auto convert_to_set = - [](std::vector categories) -> std::set { + [](auto& categories) -> std::set { std::set out; for (const auto& s : categories) { - out.emplace(s); + out.emplace(std::string(s.data(), s.size())); } return out; }; // Attach a new NodeTraceWriter only if this function hasn't been called // before. if (tracing_file_writer_.IsDefaultHandle()) { - using std::string_view_literals::operator""sv; - const std::vector categories = - SplitString(per_process::cli_options->trace_event_categories, ","sv); + using std::operator""sv; + auto categories = std::views::split( + per_process::cli_options->trace_event_categories, ","sv); tracing_file_writer_ = tracing_agent_->AddClient( convert_to_set(categories), diff --git a/src/util.cc b/src/util.cc index 173f115a162562..bc11b8cbfa05a5 100644 --- a/src/util.cc +++ b/src/util.cc @@ -220,24 +220,6 @@ std::string GetHumanReadableProcessName() { return SPrintF("%s[%d]", GetProcessTitle("Node.js"), uv_os_getpid()); } -std::vector SplitString(const std::string_view in, - const std::string_view delim) { - std::vector out; - - for (auto first = in.data(), second = in.data(), last = first + in.size(); - second != last && first != last; - first = second + 1) { - second = - std::find_first_of(first, last, std::cbegin(delim), std::cend(delim)); - - if (first != second) { - out.emplace_back(first, second - first); - } - } - - return out; -} - void ThrowErrStringTooLong(Isolate* isolate) { isolate->ThrowException(ERR_STRING_TOO_LONG(isolate)); } diff --git a/src/util.h b/src/util.h index a6da8720c499df..79874de90c50ea 100644 --- a/src/util.h +++ b/src/util.h @@ -703,8 +703,6 @@ using DeleteFnPtr = typename FunctionDeleter::Pointer; inline v8::Maybe FromV8Array(v8::Local context, v8::Local js_array, std::vector>* out); -std::vector SplitString(const std::string_view in, - const std::string_view delim); inline v8::MaybeLocal ToV8Value(v8::Local context, std::string_view str,