Skip to content
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 nop as write() callback if omitted #564

Closed
wants to merge 1 commit into from
Closed

stream: use nop as write() callback if omitted #564

wants to merge 1 commit into from

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Jan 23, 2015

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.

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() {}
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@bnoordhuis
Copy link
Member

LGTM but I suggest rewording this:

This saves on function and closure creation.

To:

This saves on function object creation.

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.)

@cjihrig
Copy link
Contributor Author

cjihrig commented Jan 23, 2015

OK, I will reword it.

cjihrig added a commit that referenced this pull request Jan 23, 2015
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>
@cjihrig
Copy link
Contributor Author

cjihrig commented Jan 23, 2015

Landed in 40ffed8

@cjihrig cjihrig closed this Jan 23, 2015
@cjihrig cjihrig deleted the nop branch January 23, 2015 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants