Skip to content

Commit ef1645e

Browse files
committed
doc: document Buffer.concat may use internal pool
PR-URL: #35541 Refs: #32703 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Harshitha K P <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Robert Nagy <[email protected]>
1 parent d9e98df commit ef1645e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

doc/api/buffer.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@ A `TypeError` will be thrown if `size` is not a number.
394394
The `Buffer` module pre-allocates an internal `Buffer` instance of
395395
size [`Buffer.poolSize`][] that is used as a pool for the fast allocation of new
396396
`Buffer` instances created using [`Buffer.allocUnsafe()`][],
397-
[`Buffer.from(array)`][], and the deprecated `new Buffer(size)` constructor only
398-
when `size` is less than or equal to `Buffer.poolSize >> 1` (floor of
399-
[`Buffer.poolSize`][] divided by two).
397+
[`Buffer.from(array)`][], [`Buffer.concat()`][], and the deprecated
398+
`new Buffer(size)` constructor only when `size` is less than or equal
399+
to `Buffer.poolSize >> 1` (floor of [`Buffer.poolSize`][] divided by two).
400400

401401
Use of this pre-allocated internal memory pool is a key difference between
402402
calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
@@ -573,6 +573,9 @@ console.log(bufA.length);
573573
// Prints: 42
574574
```
575575

576+
`Buffer.concat()` may also use the internal `Buffer` pool like
577+
[`Buffer.allocUnsafe()`][] does.
578+
576579
### Static method: `Buffer.from(array)`
577580
<!-- YAML
578581
added: v5.10.0
@@ -3321,6 +3324,7 @@ introducing security vulnerabilities into an application.
33213324
[`Buffer.alloc()`]: #buffer_static_method_buffer_alloc_size_fill_encoding
33223325
[`Buffer.allocUnsafe()`]: #buffer_static_method_buffer_allocunsafe_size
33233326
[`Buffer.allocUnsafeSlow()`]: #buffer_static_method_buffer_allocunsafeslow_size
3327+
[`Buffer.concat()`]: #buffer_static_method_buffer_concat_list_totallength
33243328
[`Buffer.from(array)`]: #buffer_static_method_buffer_from_array
33253329
[`Buffer.from(arrayBuf)`]: #buffer_static_method_buffer_from_arraybuffer_byteoffset_length
33263330
[`Buffer.from(buffer)`]: #buffer_static_method_buffer_from_buffer

0 commit comments

Comments
 (0)