From 0c877762ea37ab08b11cd242a01356629263a323 Mon Sep 17 00:00:00 2001 From: Andrey Pechkurov Date: Wed, 7 Oct 2020 17:05:39 +0300 Subject: [PATCH] doc: document Buffer.concat may use internal pool PR-URL: https://github.com/nodejs/node/pull/35541 Refs: https://github.com/nodejs/node/pull/32703 Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen Reviewed-By: Harshitha K P Reviewed-By: Rich Trott Reviewed-By: Robert Nagy --- doc/api/buffer.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 015f87a169cc86..9240f1c53a385b 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -386,9 +386,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)`][], 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.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). Use of this pre-allocated internal memory pool is a key difference between calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`. @@ -560,6 +560,9 @@ console.log(bufA.length); // Prints: 42 ``` +`Buffer.concat()` may also use the internal `Buffer` pool like +[`Buffer.allocUnsafe()`][] does. + ### Static method: `Buffer.from(array)`