mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
src: reuse cached strings in CompileSerializeMain
CompileSerializeMain() created new "require", "__filename", and "__dirname" strings via FIXED_ONE_BYTE_STRING() on every call, even though these strings are already cached on IsolateData/Environment as require_string(), __filename_string(), and __dirname_string() (defined via PER_ISOLATE_STRING_PROPERTIES in src/env_properties.h) and are reused this way elsewhere (e.g. the sibling RunEmbedderPreload() already obtains Environment* the same way). Signed-off-by: agape1225 <49804691+agape1225@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/65453 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
1 parent
b5f0558c84
commit
e260fd146c
1 file changed
+7
-7
@@ -1571,17 +1571,17 @@ void CompileSerializeMain(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK(args[0]->IsString());
|
||||
Local<String> filename = args[0].As<String>();
|
||||
Local<String> source = args[1].As<String>();
|
||||
Environment* env = Environment::GetCurrent(args);
|
||||
Isolate* isolate = args.GetIsolate();
|
||||
Local<Context> context = isolate->GetCurrentContext();
|
||||
// TODO(joyeecheung): do we need all of these? Maybe we would want a less
|
||||
// internal version of them.
|
||||
LocalVector<String> parameters(
|
||||
isolate,
|
||||
{
|
||||
FIXED_ONE_BYTE_STRING(isolate, "require"),
|
||||
FIXED_ONE_BYTE_STRING(isolate, "__filename"),
|
||||
FIXED_ONE_BYTE_STRING(isolate, "__dirname"),
|
||||
});
|
||||
LocalVector<String> parameters(isolate,
|
||||
{
|
||||
env->require_string(),
|
||||
env->__filename_string(),
|
||||
env->__dirname_string(),
|
||||
});
|
||||
|
||||
ScriptOrigin script_origin(filename, 0, 0, true);
|
||||
ScriptCompiler::Source script_source(source, script_origin);
|
||||
|
||||
Reference in new issue
Block a user