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

Avoid using deprecated Buffer constructor #90

Merged
merged 1 commit into from
Mar 21, 2018
Merged

Conversation

ChALkeR
Copy link
Contributor

@ChALkeR ChALkeR commented Feb 22, 2018

This should also give performance improvements on Node.js 8+.


Use Buffer.allocUnsafe directly on Node.js >= 4.5.0
This usecase doesn't need zero-filling, as is properly filled with the parent buffer.

This behaves exactly the same as Buffer(number) on 4.x and 6.x, and slightly faster that Buffer(number) on 8.x and above, as doesn't perform zero-fill.

Older Node.js versions (<4.5.0) use the old code path.

Refs:
https://nodejs.org/api/deprecations.html#deprecations_dep0005_buffer_constructor

Use Buffer.allocUnsafe directly on Node.js >= 4.5.0
This usecase doesn't need zero-filling, as is properly filled with the
parent buffer.

This behaves exactly the same as Buffer(number) on 4.x and 6.x, 
and slightly faster that Buffer(number) on 8.x and above, as doesn't
perform zero-fill.

Older Node.js versions (<4.5.0) use the old code path.

Refs:
https://nodejs.org/api/deprecations.html#deprecations_dep0005_buffer_constructor
@ChALkeR
Copy link
Contributor Author

ChALkeR commented Mar 2, 2018

Tracking: nodejs/node#19079

@pvorb pvorb merged commit e2a1a10 into pvorb:master Mar 21, 2018
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.

2 participants