Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit df52814

Browse filesBrowse files
puzpuzpuzMylesBorins
authored andcommitted
doc: document Buffer.concat may use internal pool
PR-URL: #35541 Refs: #32703 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Harshitha K P <harshitha014@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
1 parent 42a587f commit df52814
Copy full SHA for df52814

File tree

Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-3
lines changed
Open diff view settings
Collapse file

‎doc/api/buffer.md‎

Copy file name to clipboardExpand all lines: doc/api/buffer.md
+7-3Lines changed: 7 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ A `TypeError` will be thrown if `size` is not a number.
386386
The `Buffer` module pre-allocates an internal `Buffer` instance of
387387
size [`Buffer.poolSize`][] that is used as a pool for the fast allocation of new
388388
`Buffer` instances created using [`Buffer.allocUnsafe()`][],
389-
[`Buffer.from(array)`][], and the deprecated `new Buffer(size)` constructor only
390-
when `size` is less than or equal to `Buffer.poolSize >> 1` (floor of
391-
[`Buffer.poolSize`][] divided by two).
389+
[`Buffer.from(array)`][], [`Buffer.concat()`][], and the deprecated
390+
`new Buffer(size)` constructor only when `size` is less than or equal
391+
to `Buffer.poolSize >> 1` (floor of [`Buffer.poolSize`][] divided by two).
392392

393393
Use of this pre-allocated internal memory pool is a key difference between
394394
calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
@@ -560,6 +560,9 @@ console.log(bufA.length);
560560
// Prints: 42
561561
```
562562

563+
`Buffer.concat()` may also use the internal `Buffer` pool like
564+
[`Buffer.allocUnsafe()`][] does.
565+
563566
### Static method: `Buffer.from(array)`
564567
<!-- YAML
565568
added: v5.10.0
@@ -3259,6 +3262,7 @@ introducing security vulnerabilities into an application.
32593262
[`Buffer.alloc()`]: #buffer_static_method_buffer_alloc_size_fill_encoding
32603263
[`Buffer.allocUnsafe()`]: #buffer_static_method_buffer_allocunsafe_size
32613264
[`Buffer.allocUnsafeSlow()`]: #buffer_static_method_buffer_allocunsafeslow_size
3265+
[`Buffer.concat()`]: #buffer_static_method_buffer_concat_list_totallength
32623266
[`Buffer.from(array)`]: #buffer_static_method_buffer_from_array
32633267
[`Buffer.from(arrayBuf)`]: #buffer_static_method_buffer_from_arraybuffer_byteoffset_length
32643268
[`Buffer.from(buffer)`]: #buffer_static_method_buffer_from_buffer

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.