-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream: use arrow fns for 'this' in readable #16927
Conversation
@@ -900,20 +899,20 @@ Readable.prototype.wrap = function(stream) { | |||
|
|||
// proxy certain important events. | |||
for (var n = 0; n < kProxyEvents.length; n++) { | |||
stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n])); | |||
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the face of it, looks like self
was not required here in the first place, the block being directly under the lexical scope of constructor function.
} | ||
|
||
// when we try to consume some more bytes, simply unpause the | ||
// underlying stream. | ||
self._read = function(n) { | ||
this._read = (n) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, self was not required here in the first place I guess.
Streams is performance sensitive. Is this worth benchmarking? |
I would say no. The changes here are extremely unlikely to yield any significant difference in the performance profile. There are other changes here that could yield improvements (such as avoiding closures) but this PR should be safe. |
Landed in fe932a1, thanks for the PR! 🎉 |
PR-URL: #16927 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #16927 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #16927 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #16927 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
Using arrow functions for this in readable stream.