GeezerVison is showing github.com — buffer: move SlowBuffer to EOL · nodejs/node@0579e0e
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-iterate.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | | -const SlowBuffer = require('buffer').SlowBuffer; | | 2 | +const { Buffer } = require('buffer'); | 3 | 3 | const common = require('../common.js'); | 4 | 4 | const assert = require('assert'); | 5 | 5 |
| @@ -19,7 +19,7 @@ const methods = { | 19 | 19 | function main({ size, type, method, n }) { | 20 | 20 | const buffer = type === 'fast' ? | 21 | 21 | Buffer.alloc(size) : | 22 | | - SlowBuffer(size).fill(0); | | 22 | + Buffer.allocUnsafeSlow(size).fill(0); | 23 | 23 |
| 24 | 24 | const fn = methods[method]; | 25 | 25 |
| |
Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-read-with-byteLength.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 | const common = require('../common.js'); | | 3 | +const { Buffer } = require('buffer'); | 3 | 4 |
| 4 | 5 | const types = [ | 5 | 6 | 'IntBE', | @@ -18,7 +19,7 @@ const bench = common.createBenchmark(main, { | 18 | 19 | function main({ n, buf, type, byteLength }) { | 19 | 20 | const buff = buf === 'fast' ? | 20 | 21 | Buffer.alloc(8) : | 21 | | - require('buffer').SlowBuffer(8); | | 22 | + Buffer.allocUnsafeSlow(8); | 22 | 23 | const fn = `read${type}`; | 23 | 24 |
| 24 | 25 | buff.writeDoubleLE(0, 0); | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-read.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 | const common = require('../common.js'); | | 3 | +const { Buffer } = require('buffer'); | 3 | 4 |
| 4 | 5 | const types = [ | 5 | 6 | 'BigUInt64LE', | @@ -27,7 +28,7 @@ const bench = common.createBenchmark(main, { | 27 | 28 | function main({ n, buf, type }) { | 28 | 29 | const buff = buf === 'fast' ? | 29 | 30 | Buffer.alloc(8) : | 30 | | - require('buffer').SlowBuffer(8); | | 31 | + Buffer.allocUnsafeSlow(8); | 31 | 32 | const fn = `read${type}`; | 32 | 33 |
| 33 | 34 | buff.writeDoubleLE(0, 0); | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-slice.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 | const common = require('../common.js'); | 3 | | -const SlowBuffer = require('buffer').SlowBuffer; | | 3 | +const { Buffer } = require('buffer'); | 4 | 4 |
| 5 | 5 | const bench = common.createBenchmark(main, { | 6 | 6 | type: ['fast', 'slow', 'subarray'], | 7 | 7 | n: [1e6], | 8 | 8 | }); | 9 | 9 |
| 10 | 10 | const buf = Buffer.allocUnsafe(1024); | 11 | | -const slowBuf = new SlowBuffer(1024); | | 11 | +const slowBuf = Buffer.allocUnsafeSlow(1024); | 12 | 12 |
| 13 | 13 | function main({ n, type }) { | 14 | 14 | const b = type === 'slow' ? slowBuf : buf; | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-write.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 | const common = require('../common.js'); | 3 | | - | | 3 | +const { Buffer } = require('buffer'); | 4 | 4 | const types = [ | 5 | 5 | 'BigUInt64LE', | 6 | 6 | 'BigUInt64BE', | @@ -73,7 +73,7 @@ const byteLength = { | 73 | 73 | function main({ n, buf, type }) { | 74 | 74 | const buff = buf === 'fast' ? | 75 | 75 | Buffer.alloc(8) : | 76 | | - require('buffer').SlowBuffer(8); | | 76 | + Buffer.allocUnsafeSlow(8); | 77 | 77 | const fn = `write${type}`; | 78 | 78 |
| 79 | 79 | if (!/\d/.test(fn)) | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/buffer.md +5-27Lines changed: 5 additions & 27 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5340,28 +5340,6 @@ console.log(newBuf.toString('ascii')); | 5340 | 5340 | Because the Euro (`€`) sign is not representable in US-ASCII, it is replaced | 5341 | 5341 | with `?` in the transcoded `Buffer`. | 5342 | 5342 |
| 5343 | | -### Class: `SlowBuffer` | 5344 | | - | 5345 | | -<!-- YAML | 5346 | | -deprecated: v6.0.0 | 5347 | | ---> | 5348 | | - | 5349 | | -> Stability: 0 - Deprecated: Use [`Buffer.allocUnsafeSlow()`][] instead. | 5350 | | -
| 5351 | | -See [`Buffer.allocUnsafeSlow()`][]. This was never a class in the sense that | 5352 | | -the constructor always returned a `Buffer` instance, rather than a `SlowBuffer` | 5353 | | -instance. | 5354 | | - | 5355 | | -#### `new SlowBuffer(size)` | 5356 | | - | 5357 | | -<!-- YAML | 5358 | | -deprecated: v6.0.0 | 5359 | | ---> | 5360 | | - | 5361 | | -* `size` {integer} The desired length of the new `SlowBuffer`. | 5362 | | - | 5363 | | -See [`Buffer.allocUnsafeSlow()`][]. | 5364 | | - | 5365 | 5343 | ### Buffer constants | 5366 | 5344 |
| 5367 | 5345 | <!-- YAML | @@ -5494,11 +5472,11 @@ added: v5.10.0 | 5494 | 5472 |
| 5495 | 5473 | Node.js can be started using the `--zero-fill-buffers` command-line option to | 5496 | 5474 | cause all newly-allocated `Buffer` instances to be zero-filled upon creation by | 5497 | | -default. Without the option, buffers created with [`Buffer.allocUnsafe()`][], | 5498 | | -[`Buffer.allocUnsafeSlow()`][], and `new SlowBuffer(size)` are not zero-filled. | 5499 | | -Use of this flag can have a measurable negative impact on performance. Use the | 5500 | | -`--zero-fill-buffers` option only when necessary to enforce that newly allocated | 5501 | | -`Buffer` instances cannot contain old data that is potentially sensitive. | | 5475 | +default. Without the option, buffers created with [`Buffer.allocUnsafe()`][] and | | 5476 | +[`Buffer.allocUnsafeSlow()`][] are not zero-filled. Use of this flag can have a | | 5477 | +measurable negative impact on performance. Use the `--zero-fill-buffers` option | | 5478 | +only when necessary to enforce that newly allocated `Buffer` instances cannot | | 5479 | +contain old data that is potentially sensitive. | 5502 | 5480 |
| 5503 | 5481 | ```console | 5504 | 5482 | $ node --zero-fill-buffers | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/cli.md +1-3Lines changed: 1 addition & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3111,8 +3111,7 @@ node --watch --watch-preserve-output test.js | 3111 | 3111 | added: v6.0.0 | 3112 | 3112 | --> | 3113 | 3113 |
| 3114 | | -Automatically zero-fills all newly allocated [`Buffer`][] and [`SlowBuffer`][] | 3115 | | -instances. | | 3114 | +Automatically zero-fills all newly allocated [`Buffer`][] instances. | 3116 | 3115 |
| 3117 | 3116 | ## Environment variables | 3118 | 3117 |
| @@ -3887,7 +3886,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12 | 3887 | 3886 | [`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`]: errors.md#err_unsupported_typescript_syntax | 3888 | 3887 | [`NODE_OPTIONS`]: #node_optionsoptions | 3889 | 3888 | [`NO_COLOR`]: https://no-color.org | 3890 | | -[`SlowBuffer`]: buffer.md#class-slowbuffer | 3891 | 3889 | [`Web Storage`]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API | 3892 | 3890 | [`WebSocket`]: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket | 3893 | 3891 | [`YoungGenerationSizeFromSemiSpaceSize`]: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328 | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/deprecations.md +5-3Lines changed: 5 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -695,6 +695,9 @@ Type: End-of-Life | 695 | 695 |
| 696 | 696 | <!-- YAML | 697 | 697 | changes: | | 698 | + - version: REPLACEME | | 699 | + pr-url: https://github.com/nodejs/node/pull/58008 | | 700 | + description: End-of-Life. | 698 | 701 | - version: REPLACEME | 699 | 702 | pr-url: https://github.com/nodejs/node/pull/55175 | 700 | 703 | description: Runtime deprecation. | @@ -706,9 +709,9 @@ changes: | 706 | 709 | description: Documentation-only deprecation. | 707 | 710 | --> | 708 | 711 |
| 709 | | -Type: Runtime | | 712 | +Type: End-of-Life | 710 | 713 |
| 711 | | -The [`SlowBuffer`][] class is deprecated. Please use | | 714 | +The `SlowBuffer` class has been removed. Please use | 712 | 715 | [`Buffer.allocUnsafeSlow(size)`][] instead. | 713 | 716 |
| 714 | 717 | ### DEP0031: `ecdh.setPublicKey()` | @@ -3918,7 +3921,6 @@ upon `require('node:module').builtinModules`. | 3918 | 3921 | [`ReadStream.open()`]: fs.md#class-fsreadstream | 3919 | 3922 | [`Server.getConnections()`]: net.md#servergetconnectionscallback | 3920 | 3923 | [`Server.listen({fd: <number>})`]: net.md#serverlistenhandle-backlog-callback | 3921 | | -[`SlowBuffer`]: buffer.md#class-slowbuffer | 3922 | 3924 | [`String.prototype.toWellFormed`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toWellFormed | 3923 | 3925 | [`WriteStream.open()`]: fs.md#class-fswritestream | 3924 | 3926 | [`assert.CallTracker`]: assert.md#class-assertcalltracker | |
Collapse file Copy file name to clipboardExpand all lines: doc/contributing/writing-and-running-benchmarks.md +4-3Lines changed: 4 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -572,7 +572,7 @@ the code inside the `main` function if it's more than just declaration. | 572 | 572 | ```js | 573 | 573 | 'use strict'; | 574 | 574 | const common = require('../common.js'); | 575 | | -const { SlowBuffer } = require('node:buffer'); | | 575 | +const { Buffer } = require('node:buffer'); | 576 | 576 |
| 577 | 577 | const configs = { | 578 | 578 | // Number of operations, specified here so they show up in the report. | @@ -603,10 +603,11 @@ function main(conf) { | 603 | 603 | bench.start(); | 604 | 604 |
| 605 | 605 | // Do operations here | 606 | | - const BufferConstructor = conf.type === 'fast' ? Buffer : SlowBuffer; | 607 | 606 |
| 608 | 607 | for (let i = 0; i < conf.n; i++) { | 609 | | - new BufferConstructor(conf.size); | | 608 | + conf.type === 'fast' ? | | 609 | + Buffer.allocUnsafe(conf.size) : | | 610 | + Buffer.allocUnsafeSlow(conf.size); | 610 | 611 | } | 611 | 612 |
| 612 | 613 | // End the timer, pass in the number of operations | |
Collapse file Copy file name to clipboardExpand all lines: doc/node.1 +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -619,7 +619,7 @@ If set to 0 then V8 will choose an appropriate size of the thread pool based on | 619 | 619 | If the value provided is larger than V8's maximum, then the largest value will be chosen. | 620 | 620 | . | 621 | 621 | .It Fl -zero-fill-buffers | 622 | | -Automatically zero-fills all newly allocated Buffer and SlowBuffer instances. | | 622 | +Automatically zero-fills all newly allocated Buffer instances. | 623 | 623 | . | 624 | 624 | .It Fl c , Fl -check | 625 | 625 | Check the script's syntax without executing it. | |
|