Skip to content

Commit

Permalink
src: persist strings that are used multiple times in the environment
Browse files Browse the repository at this point in the history
PR-URL: #30321
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
bmsdave authored and MylesBorins committed Nov 17, 2019
1 parent 041f3a3 commit 70ad676
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/heap_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion src/node_process_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
2 changes: 1 addition & 1 deletion src/stream_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down

0 comments on commit 70ad676

Please sign in to comment.