-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
stream: use nop as write() callback if omitted #564
Conversation
This commit introduces a nop function that is used as the Writable.prototype.write() callback when one is not provided. This saves on function and closure creation.
@@ -13,6 +13,8 @@ const debug = util.debuglog('stream'); | |||
|
|||
util.inherits(Writable, Stream); | |||
|
|||
function nop() {} |
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.
s/nop/noop/ ? I have only ever seen the latter.
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.
I think both exist in core.
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.
Yea, I personally prefer noop, but nop seems to be used in core too.
LGTM but I suggest rewording this:
To:
Empty functions don't allocate a closure context (they don't close over anything) but they still create a function object (when passed around as values.) |
OK, I will reword it. |
This commit introduces a nop function that is used as the Writable.prototype.write() callback when one is not provided. This saves on function object creation. PR-URL: #564 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Landed in 40ffed8 |
This commit introduces a nop function that is used as the
Writable.prototype.write()
callback when one is not provided. This saves on function and closure creation.