lib: move process prototype manipulation into setupProcessObject
Since no operation is requiring process to be an EventEmitter before setupProcessObject is called, it's safe to set up the prototype chain in setupProcessObject and make the main code path more readable. PR-URL: https://github.com/nodejs/node/pull/24089 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
7bd8bbaabf
commit
56ce6f191d
@ -30,13 +30,6 @@
|
||||
const isMainThread = internalBinding('worker').threadId === 0;
|
||||
|
||||
function startup() {
|
||||
const EventEmitter = NativeModule.require('events');
|
||||
|
||||
const origProcProto = Object.getPrototypeOf(process);
|
||||
Object.setPrototypeOf(origProcProto, EventEmitter.prototype);
|
||||
|
||||
EventEmitter.call(process);
|
||||
|
||||
setupTraceCategoryState();
|
||||
|
||||
setupProcessObject();
|
||||
@ -378,6 +371,11 @@
|
||||
}
|
||||
|
||||
function setupProcessObject() {
|
||||
const EventEmitter = NativeModule.require('events');
|
||||
const origProcProto = Object.getPrototypeOf(process);
|
||||
Object.setPrototypeOf(origProcProto, EventEmitter.prototype);
|
||||
EventEmitter.call(process);
|
||||
|
||||
_setupProcessObject(pushValueToArray);
|
||||
|
||||
function pushValueToArray() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user