diff options
author | Brian White <mscdex@mscdex.net> | 2016-12-18 21:25:31 -0500 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2016-12-29 14:19:03 -0500 |
commit | b6ea857c7dabf65c2826c269bb4c8a94fecf40ca (patch) | |
tree | 40c8f75748b3da95c9c21bccc14e714b236027af /lib/_http_outgoing.js | |
parent | a54972c195f708afbd985d981b804834817da92b (diff) | |
download | android-node-v8-b6ea857c7dabf65c2826c269bb4c8a94fecf40ca.tar.gz android-node-v8-b6ea857c7dabf65c2826c269bb4c8a94fecf40ca.tar.bz2 android-node-v8-b6ea857c7dabf65c2826c269bb4c8a94fecf40ca.zip |
lib: avoid recompilation of anonymous functions
Since at least V8 5.4, using function.bind() is now fast enough to
use to avoid recompiling/reoptimizing the same anonymous functions.
These changes especially impact http servers.
PR-URL: https://github.com/nodejs/node/pull/6533
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'lib/_http_outgoing.js')
-rw-r--r-- | lib/_http_outgoing.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 8d134ecc50..5a9e34bedd 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -545,6 +545,9 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { const crlf_buf = Buffer.from('\r\n'); +function onFinish(outmsg) { + outmsg.emit('finish'); +} OutgoingMessage.prototype.end = function end(data, encoding, callback) { if (typeof data === 'function') { @@ -592,9 +595,7 @@ OutgoingMessage.prototype.end = function end(data, encoding, callback) { if (typeof callback === 'function') this.once('finish', callback); - const finish = () => { - this.emit('finish'); - }; + var finish = onFinish.bind(undefined, this); var ret; if (this._hasBody && this.chunkedEncoding) { |