doc: update Buffer.allocUnsafe description
PR-URL: https://github.com/nodejs/node/pull/48183 Fixes: https://github.com/nodejs/node/issues/42821 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
20080f9a19
commit
1e3631f0e3
@ -807,10 +807,9 @@ A `TypeError` will be thrown if `size` is not a number.
|
||||
|
||||
The `Buffer` module pre-allocates an internal `Buffer` instance of
|
||||
size [`Buffer.poolSize`][] that is used as a pool for the fast allocation of new
|
||||
`Buffer` instances created using [`Buffer.allocUnsafe()`][],
|
||||
[`Buffer.from(array)`][], [`Buffer.concat()`][], and the deprecated
|
||||
`new Buffer(size)` constructor only when `size` is less than or equal
|
||||
to `Buffer.poolSize >> 1` (floor of [`Buffer.poolSize`][] divided by two).
|
||||
`Buffer` instances created using [`Buffer.allocUnsafe()`][], [`Buffer.from(array)`][],
|
||||
and [`Buffer.concat()`][] only when `size` is less than or equal to
|
||||
`Buffer.poolSize >> 1` (floor of [`Buffer.poolSize`][] divided by two).
|
||||
|
||||
Use of this pre-allocated internal memory pool is a key difference between
|
||||
calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user