mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
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:
1 parent
6a6b036042
commit
453c96ed2d
1 file changed
+5
-7
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user