GeezerVison is showing github.com — src: replace `SplitString` with built-in · nodejs/node@6b398d6
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/node_options.cc +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -53,19 +53,19 @@ void DebugOptions::CheckOptions(std::vector<std::string>* errors, | 53 | 53 | "`node --inspect-brk` instead."); | 54 | 54 | } | 55 | 55 |
| 56 | | - using std::string_view_literals::operator""sv; | 57 | | - const std::vector<std::string_view> destinations = | 58 | | - SplitString(inspect_publish_uid_string, ","sv); | | 56 | + using std::operator""sv; | | 57 | + auto entries = std::views::split(inspect_publish_uid_string, ","sv); | 59 | 58 | inspect_publish_uid.console = false; | 60 | 59 | inspect_publish_uid.http = false; | 61 | | - for (const std::string_view destination : destinations) { | | 60 | + for (const auto& entry : entries) { | | 61 | + std::string_view destination(entry.data(), entry.size()); | 62 | 62 | if (destination == "stderr"sv) { | 63 | 63 | inspect_publish_uid.console = true; | 64 | 64 | } else if (destination == "http"sv) { | 65 | 65 | inspect_publish_uid.http = true; | 66 | 66 | } else { | 67 | | - errors->push_back("--inspect-publish-uid destination can be " | 68 | | - "stderr or http"); | | 67 | + errors->emplace_back("--inspect-publish-uid destination can be " | | 68 | + "stderr or http"); | 69 | 69 | } | 70 | 70 | } | 71 | 71 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/node_v8_platform-inl.h +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -128,19 +128,19 @@ struct V8Platform { | 128 | 128 |
| 129 | 129 | inline void StartTracingAgent() { | 130 | 130 | constexpr auto convert_to_set = | 131 | | - [](std::vector<std::string_view> categories) -> std::set<std::string> { | | 131 | + [](auto& categories) -> std::set<std::string> { | 132 | 132 | std::set<std::string> out; | 133 | 133 | for (const auto& s : categories) { | 134 | | - out.emplace(s); | | 134 | + out.emplace(std::string(s.data(), s.size())); | 135 | 135 | } | 136 | 136 | return out; | 137 | 137 | }; | 138 | 138 | // Attach a new NodeTraceWriter only if this function hasn't been called | 139 | 139 | // before. | 140 | 140 | if (tracing_file_writer_.IsDefaultHandle()) { | 141 | | - using std::string_view_literals::operator""sv; | 142 | | - const std::vector<std::string_view> categories = | 143 | | - SplitString(per_process::cli_options->trace_event_categories, ","sv); | | 141 | + using std::operator""sv; | | 142 | + auto categories = std::views::split( | | 143 | + per_process::cli_options->trace_event_categories, ","sv); | 144 | 144 |
| 145 | 145 | tracing_file_writer_ = tracing_agent_->AddClient( | 146 | 146 | convert_to_set(categories), | |
Collapse file Copy file name to clipboardExpand all lines: src/util.cc -18Lines changed: 0 additions & 18 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -220,24 +220,6 @@ std::string GetHumanReadableProcessName() { | 220 | 220 | return SPrintF("%s[%d]", GetProcessTitle("Node.js"), uv_os_getpid()); | 221 | 221 | } | 222 | 222 |
| 223 | | -std::vector<std::string_view> SplitString(const std::string_view in, | 224 | | - const std::string_view delim) { | 225 | | - std::vector<std::string_view> out; | 226 | | - | 227 | | - for (auto first = in.data(), second = in.data(), last = first + in.size(); | 228 | | - second != last && first != last; | 229 | | - first = second + 1) { | 230 | | - second = | 231 | | - std::find_first_of(first, last, std::cbegin(delim), std::cend(delim)); | 232 | | - | 233 | | - if (first != second) { | 234 | | - out.emplace_back(first, second - first); | 235 | | - } | 236 | | - } | 237 | | - | 238 | | - return out; | 239 | | -} | 240 | | - | 241 | 223 | void ThrowErrStringTooLong(Isolate* isolate) { | 242 | 224 | isolate->ThrowException(ERR_STRING_TOO_LONG(isolate)); | 243 | 225 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/util.h -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -715,8 +715,6 @@ using DeleteFnPtr = typename FunctionDeleter<T, function>::Pointer; | 715 | 715 | inline v8::Maybe<void> FromV8Array(v8::Local<v8::Context> context, | 716 | 716 | v8::Local<v8::Array> js_array, | 717 | 717 | std::vector<v8::Global<v8::Value>>* out); | 718 | | -std::vector<std::string_view> SplitString(const std::string_view in, | 719 | | - const std::string_view delim); | 720 | 718 |
| 721 | 719 | inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context, | 722 | 720 | std::string_view str, | |
|