Skip to content
Permalink
Browse files

src: persist strings that are used multiple times in the environment

PR-URL: #30321
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
bmsdave authored and MylesBorins committed Nov 6, 2019
1 parent b0816c2 commit d8046fc0f824d736bf0b0d11d154f8d487b705a5
Showing with 6 additions and 5 deletions.
  1. +4 −3 src/heap_utils.cc
  2. +1 −1 src/node_process_object.cc
  3. +1 −1 src/stream_wrap.cc
@@ -89,14 +89,15 @@ class JSGraph : public EmbedderGraph {
MaybeLocal<Array> CreateObject() const {
EscapableHandleScope handle_scope(isolate_);
Local<Context> context = isolate_->GetCurrentContext();
Environment* env = Environment::GetCurrent(context);

std::unordered_map<Node*, Local<Object>> info_objects;
Local<Array> nodes = Array::New(isolate_, nodes_.size());
Local<String> edges_string = FIXED_ONE_BYTE_STRING(isolate_, "edges");
Local<String> is_root_string = FIXED_ONE_BYTE_STRING(isolate_, "isRoot");
Local<String> name_string = FIXED_ONE_BYTE_STRING(isolate_, "name");
Local<String> size_string = FIXED_ONE_BYTE_STRING(isolate_, "size");
Local<String> value_string = FIXED_ONE_BYTE_STRING(isolate_, "value");
Local<String> name_string = env->name_string();
Local<String> size_string = env->size_string();
Local<String> value_string = env->value_string();
Local<String> wraps_string = FIXED_ONE_BYTE_STRING(isolate_, "wraps");
Local<String> to_string = FIXED_ONE_BYTE_STRING(isolate_, "to");

@@ -74,7 +74,7 @@ MaybeLocal<Object> CreateProcessObject(Environment* env) {
Local<Context> context = env->context();

Local<FunctionTemplate> process_template = FunctionTemplate::New(isolate);
process_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "process"));
process_template->SetClassName(env->process_string());
Local<Function> process_ctor;
Local<Object> process;
if (!process_template->GetFunction(context).ToLocal(&process_ctor) ||
@@ -78,7 +78,7 @@ void LibuvStreamWrap::Initialize(Local<Object> 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()));

0 comments on commit d8046fc

Please sign in to comment.
You can’t perform that action at this time.