| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -282,9 +282,12 @@ static struct { | |||
| 282 | 282 | if (per_process::cli_options->trace_event_categories.empty()) { | |
| 283 | 283 | tracing_file_writer_ = tracing_agent_->DefaultHandle(); | |
| 284 | 284 | } else { | |
| 285 | + std::vector<std::string> categories = | ||
| 286 | + SplitString(per_process::cli_options->trace_event_categories, ','); | ||
| 287 | + | ||
| 285 | 288 | 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())), | ||
| 288 | 291 | std::unique_ptr<tracing::AsyncTraceWriter>( | |
| 289 | 292 | new tracing::NodeTraceWriter( | |
| 290 | 293 | per_process::cli_options->trace_event_file_pattern)), | |
@@ -1424,23 +1427,10 @@ void Init(std::vector<std::string>* argv, | |||
| 1424 | 1427 | #if !defined(NODE_WITHOUT_NODE_OPTIONS) | |
| 1425 | 1428 | std::string node_options; | |
| 1426 | 1429 | 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); | ||
| 1444 | 1434 | ||
| 1445 | 1435 | ProcessArgv(&env_argv, nullptr, true); | |
| 1446 | 1436 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,15 +122,15 @@ void GetHumanReadableProcessName(char (*name)[1024]) { | |||
| 122 | 122 | snprintf(*name, sizeof(*name), "%s[%d]", title, uv_os_getpid()); | |
| 123 | 123 | } | |
| 124 | 124 | ||
| 125 | - std::set<std::string> ParseCommaSeparatedSet(const std::string& in) { | ||
| 126 | - std::set<std::string> out; | ||
| 125 | + std::vector<std::string> SplitString(const std::string& in, char delim) { | ||
| 126 | + std::vector<std::string> out; | ||
| 127 | 127 | if (in.empty()) | |
| 128 | 128 | return out; | |
| 129 | 129 | std::istringstream in_stream(in); | |
| 130 | 130 | while (in_stream.good()) { | |
| 131 | 131 | std::string item; | |
| 132 | - getline(in_stream, item, ','); | ||
| 133 | - out.emplace(std::move(item)); | ||
| 132 | + std::getline(in_stream, item, delim); | ||
| 133 | + out.emplace_back(std::move(item)); | ||
| 134 | 134 | } | |
| 135 | 135 | return out; | |
| 136 | 136 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -523,7 +523,7 @@ struct FunctionDeleter { | |||
| 523 | 523 | template <typename T, void (*function)(T*)> | |
| 524 | 524 | using DeleteFnPtr = typename FunctionDeleter<T, function>::Pointer; | |
| 525 | 525 | ||
| 526 | - std::set<std::string> ParseCommaSeparatedSet(const std::string& in); | ||
| 526 | + std::vector<std::string> SplitString(const std::string& in, char delim); | ||
| 527 | 527 | ||
| 528 | 528 | inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context, | |
| 529 | 529 | const std::string& str, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments