src: use CreateEnvironment instead of inlining its code where possible · nodejs/node@b995138 · GitHub
Skip to content

Commit b995138

Browse files
addaleaxRafaelGSS
authored andcommitted
src: use CreateEnvironment instead of inlining its code where possible
We had a number of places in which we created an `Environment` instance by performing each step in `CreateEnvironment` manually. Instead, just call the function itself. PR-URL: #45886 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent cf2ff81 commit b995138

3 files changed

Lines changed: 21 additions & 26 deletions

File tree

src/api/environment.cc

Lines changed: 4 additions & 3 deletions

src/node_main_instance.cc

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,8 @@ NodeMainInstance::CreateMainEnvironment(ExitCode* exit_code) {
191191
context = NewContext(isolate_);
192192
CHECK(!context.IsEmpty());
193193
Context::Scope context_scope(context);
194-
env.reset(new Environment(isolate_data_.get(),
195-
context,
196-
args_,
197-
exec_args_,
198-
nullptr,
199-
EnvironmentFlags::kDefaultFlags,
200-
{}));
201-
#if HAVE_INSPECTOR
202-
env->InitializeInspector({});
203-
#endif
204-
if (env->principal_realm()->RunBootstrapping().IsEmpty()) {
205-
return nullptr;
206-
}
194+
env.reset(
195+
CreateEnvironment(isolate_data_.get(), context, args_, exec_args_));
207196
}
208197

209198
return env;

src/node_snapshotable.cc

Lines changed: 15 additions & 10 deletions

0 commit comments

Comments
 (0)