Commit 51587b22 authored by alejandro's avatar alejandro Committed by James M Snell
Browse files

buffer: preallocate array with buffer length

Because the final array length is known, it's better to allocate its
final length at initialization time to avoid future reallocations.

Also add an explicit buffer length greater than 0 comparison so
it's more readable, avoids the internal ToBoolean call and follows the
standard Node.js API format (as it can be checked in other similar
structures where 'length > 0' is preferred over 'length')

PR-URL: https://github.com/nodejs/node/pull/11733


Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
Reviewed-By: default avatarAnna Henningsen <anna@addaleax.net>
Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
Reviewed-By: default avatarBrian White <mscdex@mscdex.net>
parent ebeee853
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment