mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
src: use std::string for trace enabled_categories
A std::string manages its own memory, so using one removes the implicit assumption that the argv vector passed to node will never be deallocated. Also, the enabled_categories are used to construct a std::stringstream, so its simpler to use the standard library consistently. PR-URL: https://github.com/nodejs/node/pull/12242 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
parent
2d3d4ccb98
commit
809ca2ff8f
@ -173,7 +173,7 @@ static node_module* modlist_builtin;
|
||||
static node_module* modlist_linked;
|
||||
static node_module* modlist_addon;
|
||||
static bool trace_enabled = false;
|
||||
static const char* trace_enabled_categories = nullptr;
|
||||
static std::string trace_enabled_categories; // NOLINT(runtime/string)
|
||||
|
||||
#if defined(NODE_HAVE_I18N_SUPPORT)
|
||||
// Path to ICU data (for i18n / Intl)
|
||||
|
@ -10,10 +10,11 @@ namespace node {
|
||||
namespace tracing {
|
||||
|
||||
using v8::platform::tracing::TraceConfig;
|
||||
using std::string;
|
||||
|
||||
Agent::Agent() {}
|
||||
|
||||
void Agent::Start(v8::Platform* platform, const char* enabled_categories) {
|
||||
void Agent::Start(v8::Platform* platform, const string& enabled_categories) {
|
||||
platform_ = platform;
|
||||
|
||||
int err = uv_loop_init(&tracing_loop_);
|
||||
@ -26,7 +27,7 @@ void Agent::Start(v8::Platform* platform, const char* enabled_categories) {
|
||||
tracing_controller_ = new TracingController();
|
||||
|
||||
TraceConfig* trace_config = new TraceConfig();
|
||||
if (enabled_categories) {
|
||||
if (!enabled_categories.empty()) {
|
||||
std::stringstream category_list(enabled_categories);
|
||||
while (category_list.good()) {
|
||||
std::string category;
|
||||
|
@ -12,7 +12,7 @@ namespace tracing {
|
||||
class Agent {
|
||||
public:
|
||||
explicit Agent();
|
||||
void Start(v8::Platform* platform, const char* enabled_categories);
|
||||
void Start(v8::Platform* platform, const std::string& enabled_categories);
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user