@@ -282,9 +282,12 @@ static struct {
282282 if (per_process::cli_options->trace_event_categories.empty()) {
283283 tracing_file_writer_ = tracing_agent_->DefaultHandle();
284284 } else {
285+ std::vector<std::string> categories =
286+ SplitString(per_process::cli_options->trace_event_categories, ',');
287+
285288 tracing_file_writer_ = tracing_agent_->AddClient(
286- ParseCommaSeparatedSet(
287- per_process::cli_options->trace_event_categories ),
289+ std::set<std::string>(std::make_move_iterator(categories.begin()),
290+ std::make_move_iterator(categories.end()) ),
288291 std::unique_ptr<tracing::AsyncTraceWriter>(
289292 new tracing::NodeTraceWriter(
290293 per_process::cli_options->trace_event_file_pattern)),
@@ -1424,23 +1427,10 @@ void Init(std::vector<std::string>* argv,
14241427#if !defined(NODE_WITHOUT_NODE_OPTIONS)
14251428 std::string node_options;
14261429 if (credentials::SafeGetenv("NODE_OPTIONS", &node_options)) {
1427- std::vector<std::string> env_argv;
1428- // [0] is expected to be the program name, fill it in from the real argv.
1429- env_argv.push_back(argv->at(0));
1430-
1431- // Split NODE_OPTIONS at each ' ' character.
1432- std::string::size_type index = std::string::npos;
1433- do {
1434- std::string::size_type prev_index = index;
1435- index = node_options.find(' ', index + 1);
1436- if (index - prev_index == 1) continue;
1437-
1438- const std::string option = node_options.substr(
1439- prev_index + 1, index - prev_index - 1);
1440- if (!option.empty())
1441- env_argv.emplace_back(std::move(option));
1442- } while (index != std::string::npos);
1443-
1430+ // [0] is expected to be the program name, fill it in from the real argv
1431+ // and use 'x' as a placeholder while parsing.
1432+ std::vector<std::string> env_argv = SplitString("x " + node_options, ' ');
1433+ env_argv[0] = argv->at(0);
14441434
14451435 ProcessArgv(&env_argv, nullptr, true);
14461436 }
0 commit comments