Skip to content

Commit

Permalink
fixup! lib: revert primordials in a hot path
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Apr 15, 2021
1 parent b2c7298 commit ed49b52
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/_http_server.js
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/async_hooks.js
Expand Up @@ -5,7 +5,6 @@ const {
ArrayPrototypeSlice,
ArrayPrototypeUnshift,
ErrorCaptureStackTrace,
FunctionPrototypeBind,
ObjectPrototypeHasOwnProperty,
ObjectDefineProperty,
Promise,
Expand Down Expand Up @@ -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', {
Expand Down
10 changes: 5 additions & 5 deletions lib/net.js
Expand Up @@ -34,7 +34,6 @@ const {
NumberParseInt,
ObjectDefineProperty,
ObjectSetPrototypeOf,
ReflectApply,
Symbol,
} = primordials;

Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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);
};


Expand Down

0 comments on commit ed49b52

Please sign in to comment.