| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e4e80c5 commit daced4a
23 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 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 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 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); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 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); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,14 @@ | |||
| 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; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 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)) | |
| 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 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3120,8 +3120,7 @@ node --watch --watch-preserve-output test.js | |||
| 3120 | 3120 | added: v6.0.0 | |
| 3121 | 3121 | --> | |
| 3122 | 3122 | ||
| 3123 | - Automatically zero-fills all newly allocated [`Buffer`][] and [`SlowBuffer`][] | ||
| 3124 | - instances. | ||
| 3123 | + Automatically zero-fills all newly allocated [`Buffer`][] instances. | ||
| 3125 | 3124 | ||
| 3126 | 3125 | ## Environment variables | |
| 3127 | 3126 | ||
@@ -3896,7 +3895,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12 | |||
| 3896 | 3895 | [`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`]: errors.md#err_unsupported_typescript_syntax | |
| 3897 | 3896 | [`NODE_OPTIONS`]: #node_optionsoptions | |
| 3898 | 3897 | [`NO_COLOR`]: https://no-color.org | |
| 3899 | - [`SlowBuffer`]: buffer.md#class-slowbuffer | ||
| 3900 | 3898 | [`Web Storage`]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API | |
| 3901 | 3899 | [`WebSocket`]: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket | |
| 3902 | 3900 | [`YoungGenerationSizeFromSemiSpaceSize`]: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328 | |
| 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/58220 | ||
| 700 | + description: End-of-Life. | ||
| 698 | 701 | - version: v24.0.0 | |
| 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()` | |
@@ -3922,7 +3925,6 @@ upon `require('node:module').builtinModules`. | |||
| 3922 | 3925 | [`ReadStream.open()`]: fs.md#class-fsreadstream | |
| 3923 | 3926 | [`Server.getConnections()`]: net.md#servergetconnectionscallback | |
| 3924 | 3927 | [`Server.listen({fd: <number>})`]: net.md#serverlistenhandle-backlog-callback | |
| 3925 | - [`SlowBuffer`]: buffer.md#class-slowbuffer | ||
| 3926 | 3928 | [`String.prototype.toWellFormed`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toWellFormed | |
| 3927 | 3929 | [`WriteStream.open()`]: fs.md#class-fswritestream | |
| 3928 | 3930 | [`assert`]: assert.md | |
| 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 | |
| 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. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments