From 11918d705fee418fb78bfdc65b0900a30b1a0ad2 Mon Sep 17 00:00:00 2001 From: sinkhaha <1468709106@qq.com> Date: Tue, 30 May 2023 03:48:13 +0800 Subject: [PATCH] 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 Reviewed-By: Luigi Pinca --- doc/api/buffer.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index d457df43775874..4ef77573adfe67 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -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)`.