From 70ad676023e29f1e030edaa13d4387377a32d0ea Mon Sep 17 00:00:00 2001 From: Vadim Gorbachev Date: Wed, 6 Nov 2019 19:28:08 +0300 Subject: [PATCH] src: persist strings that are used multiple times in the environment PR-URL: https://github.com/nodejs/node/pull/30321 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: David Carlier Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig --- src/heap_utils.cc | 7 ++++--- src/node_process_object.cc | 2 +- src/stream_wrap.cc | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/heap_utils.cc b/src/heap_utils.cc index 8391f1de3726c1..b996f78aa4199b 100644 --- a/src/heap_utils.cc +++ b/src/heap_utils.cc @@ -89,14 +89,15 @@ class JSGraph : public EmbedderGraph { MaybeLocal CreateObject() const { EscapableHandleScope handle_scope(isolate_); Local context = isolate_->GetCurrentContext(); + Environment* env = Environment::GetCurrent(context); std::unordered_map> info_objects; Local nodes = Array::New(isolate_, nodes_.size()); Local edges_string = FIXED_ONE_BYTE_STRING(isolate_, "edges"); Local is_root_string = FIXED_ONE_BYTE_STRING(isolate_, "isRoot"); - Local name_string = FIXED_ONE_BYTE_STRING(isolate_, "name"); - Local size_string = FIXED_ONE_BYTE_STRING(isolate_, "size"); - Local value_string = FIXED_ONE_BYTE_STRING(isolate_, "value"); + Local name_string = env->name_string(); + Local size_string = env->size_string(); + Local value_string = env->value_string(); Local wraps_string = FIXED_ONE_BYTE_STRING(isolate_, "wraps"); Local to_string = FIXED_ONE_BYTE_STRING(isolate_, "to"); diff --git a/src/node_process_object.cc b/src/node_process_object.cc index 92124503ab9c5c..a1bf90c8d69fc0 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -74,7 +74,7 @@ MaybeLocal CreateProcessObject(Environment* env) { Local context = env->context(); Local process_template = FunctionTemplate::New(isolate); - process_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "process")); + process_template->SetClassName(env->process_string()); Local process_ctor; Local process; if (!process_template->GetFunction(context).ToLocal(&process_ctor) || diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index 1ec8386fbbb534..21b775401e4571 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -78,7 +78,7 @@ void LibuvStreamWrap::Initialize(Local target, // - callback // - handle sw->InstanceTemplate()->Set( - FIXED_ONE_BYTE_STRING(env->isolate(), "oncomplete"), + env->oncomplete_string(), v8::Null(env->isolate())); sw->InstanceTemplate()->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "callback"), v8::Null(env->isolate()));