From ed49b52609d4b0afb2bddc0b8e2374859c6ce0ce Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 15 Apr 2021 15:55:37 +0200 Subject: [PATCH] fixup! lib: revert primordials in a hot path --- lib/_http_server.js | 2 +- lib/internal/async_hooks.js | 3 +-- lib/net.js | 10 +++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index d383c1901c9029..488ed55016e390 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -626,7 +626,7 @@ function socketOnData(server, socket, parser, state, d) { function onRequestTimeout(socket) { socket[kRequestTimeout] = undefined; // socketOnError has additional logic and will call socket.destroy(err). - ReflectApply(socketOnError, socket, [new ERR_HTTP_REQUEST_TIMEOUT()]); + FunctionPrototypeCall(socketOnError, socket, new ERR_HTTP_REQUEST_TIMEOUT()); } function onParserExecute(server, socket, parser, state, ret) { diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 69ca8d6db987ed..8756ab1fb49d53 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -5,7 +5,6 @@ const { ArrayPrototypeSlice, ArrayPrototypeUnshift, ErrorCaptureStackTrace, - FunctionPrototypeBind, ObjectPrototypeHasOwnProperty, ObjectDefineProperty, Promise, @@ -256,7 +255,7 @@ function emitHook(symbol, asyncId) { } function emitHookFactory(symbol, name) { - const fn = FunctionPrototypeBind(emitHook, undefined, symbol); + const fn = emitHook.bind(undefined, symbol); // Set the name property of the function as it looks good in the stack trace. ObjectDefineProperty(fn, 'name', { diff --git a/lib/net.js b/lib/net.js index 07ec3c80d63372..8e158d79829eab 100644 --- a/lib/net.js +++ b/lib/net.js @@ -34,7 +34,6 @@ const { NumberParseInt, ObjectDefineProperty, ObjectSetPrototypeOf, - ReflectApply, Symbol, } = primordials; @@ -440,8 +439,8 @@ function afterShutdown() { // is overly vague, and makes it seem like the user's code is to blame. function writeAfterFIN(chunk, encoding, cb) { if (!this.writableEnded) { - return ReflectApply( - stream.Duplex.prototype.write, this, [chunk, encoding, cb]); + return FunctionPrototypeCall( + stream.Duplex.prototype.write, this, chunk, encoding, cb); } if (typeof encoding === 'function') { @@ -585,7 +584,8 @@ Socket.prototype._read = function(n) { Socket.prototype.end = function(data, encoding, callback) { - ReflectApply(stream.Duplex.prototype.end, this, [data, encoding, callback]); + FunctionPrototypeCall(stream.Duplex.prototype.end, this, + data, encoding, callback); DTRACE_NET_STREAM_END(this); return this; }; @@ -619,7 +619,7 @@ Socket.prototype.read = function(n) { !this._handle.reading) { tryReadStart(this); } - return ReflectApply(stream.Duplex.prototype.read, this, [n]); + return FunctionPrototypeCall(stream.Duplex.prototype.read, this, n); };