Skip to content

Commit

Permalink
src: use kInternalized instead of kNormal
Browse files Browse the repository at this point in the history
Use v8::NewStringType::kInternalized instead of
v8::NewStringType::kNormal in different calls to v8::String::NewFromUtf8
in node.h and node.cc wherever it makes sense, to save the GC some work
which would largely be redundant.

PR-URL: #21926
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
ryzokuken authored and targos committed Jul 31, 2018
1 parent 2c95b96 commit 6b6a26b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2351,11 +2351,11 @@ void SetupProcessObject(Environment* env,
if (uv_exepath(exec_path, &exec_path_len) == 0) {
exec_path_value = String::NewFromUtf8(env->isolate(),
exec_path,
v8::NewStringType::kNormal,
v8::NewStringType::kInternalized,
exec_path_len).ToLocalChecked();
} else {
exec_path_value = String::NewFromUtf8(env->isolate(), argv[0],
v8::NewStringType::kNormal).ToLocalChecked();
v8::NewStringType::kInternalized).ToLocalChecked();
}
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "execPath"),
exec_path_value);
Expand Down
8 changes: 4 additions & 4 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ NODE_EXTERN struct uv_loop_s* GetCurrentEventLoop(v8::Isolate* isolate);
v8::Local<v8::Context> context = isolate->GetCurrentContext(); \
v8::Local<v8::String> constant_name = \
v8::String::NewFromUtf8(isolate, #constant, \
v8::NewStringType::kNormal).ToLocalChecked(); \
v8::NewStringType::kInternalized).ToLocalChecked(); \
v8::Local<v8::Number> constant_value = \
v8::Number::New(isolate, static_cast<double>(constant)); \
v8::PropertyAttribute constant_attributes = \
Expand Down Expand Up @@ -346,7 +346,7 @@ inline void NODE_SET_METHOD(v8::Local<v8::Template> recv,
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate,
callback);
v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
v8::NewStringType::kNormal).ToLocalChecked();
v8::NewStringType::kInternalized).ToLocalChecked();
t->SetClassName(fn_name);
recv->Set(fn_name, t);
}
Expand All @@ -361,7 +361,7 @@ inline void NODE_SET_METHOD(v8::Local<v8::Object> recv,
callback);
v8::Local<v8::Function> fn = t->GetFunction();
v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
v8::NewStringType::kNormal).ToLocalChecked();
v8::NewStringType::kInternalized).ToLocalChecked();
fn->SetName(fn_name);
recv->Set(fn_name, fn);
}
Expand All @@ -378,7 +378,7 @@ inline void NODE_SET_PROTOTYPE_METHOD(v8::Local<v8::FunctionTemplate> recv,
v8::Local<v8::FunctionTemplate> t =
v8::FunctionTemplate::New(isolate, callback, v8::Local<v8::Value>(), s);
v8::Local<v8::String> fn_name = v8::String::NewFromUtf8(isolate, name,
v8::NewStringType::kNormal).ToLocalChecked();
v8::NewStringType::kInternalized).ToLocalChecked();
t->SetClassName(fn_name);
recv->PrototypeTemplate()->Set(fn_name, t);
}
Expand Down

0 comments on commit 6b6a26b

Please sign in to comment.