| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -354,13 +354,13 @@ Buffer.copyBytesFrom = function copyBytesFrom(view, offset, length) { | |||
| 354 | 354 | ||
| 355 | 355 | const viewLength = TypedArrayPrototypeGetLength(view); | |
| 356 | 356 | if (viewLength === 0) { | |
| 357 | - return Buffer.alloc(0); | ||
| 357 | + return new FastBuffer(); | ||
| 358 | 358 | } | |
| 359 | 359 | ||
| 360 | 360 | if (offset !== undefined || length !== undefined) { | |
| 361 | 361 | if (offset !== undefined) { | |
| 362 | 362 | validateInteger(offset, 'offset', 0); | |
| 363 | - if (offset >= viewLength) return Buffer.alloc(0); | ||
| 363 | + if (offset >= viewLength) return new FastBuffer(); | ||
| 364 | 364 | } else { | |
| 365 | 365 | offset = 0; | |
| 366 | 366 | } | |
@@ -1274,7 +1274,7 @@ if (internalBinding('config').hasIntl) { | |||
| 1274 | 1274 | throw new ERR_INVALID_ARG_TYPE('source', | |
| 1275 | 1275 | ['Buffer', 'Uint8Array'], source); | |
| 1276 | 1276 | } | |
| 1277 | - if (source.length === 0) return Buffer.alloc(0); | ||
| 1277 | + if (source.length === 0) return new FastBuffer(); | ||
| 1278 | 1278 | ||
| 1279 | 1279 | fromEncoding = normalizeEncoding(fromEncoding) || fromEncoding; | |
| 1280 | 1280 | toEncoding = normalizeEncoding(toEncoding) || toEncoding; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,6 +74,7 @@ const { | |||
| 74 | 74 | defaultTriggerAsyncIdScope, | |
| 75 | 75 | symbols: { async_id_symbol, owner_symbol }, | |
| 76 | 76 | } = require('internal/async_hooks'); | |
| 77 | + const { FastBuffer } = require('internal/buffer'); | ||
| 77 | 78 | const { UV_UDP_REUSEADDR } = internalBinding('constants').os; | |
| 78 | 79 | ||
| 79 | 80 | const { | |
@@ -689,7 +690,7 @@ Socket.prototype.send = function(buffer, | |||
| 689 | 690 | this.bind({ port: 0, exclusive: true }, null); | |
| 690 | 691 | ||
| 691 | 692 | if (list.length === 0) | |
| 692 | - ArrayPrototypePush(list, Buffer.alloc(0)); | ||
| 693 | + ArrayPrototypePush(list, new FastBuffer()); | ||
| 693 | 694 | ||
| 694 | 695 | // If the socket hasn't been bound yet, push the outbound packet onto the | |
| 695 | 696 | // send queue and send after binding is complete. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,7 @@ const { ERR_DEBUGGER_ERROR } = require('internal/errors').codes; | |||
| 16 | 16 | const { EventEmitter, once } = require('events'); | |
| 17 | 17 | const http = require('http'); | |
| 18 | 18 | const { URL } = require('internal/url'); | |
| 19 | + const { FastBuffer } = require('internal/buffer'); | ||
| 19 | 20 | ||
| 20 | 21 | const debuglog = require('internal/util/debuglog').debuglog('inspect'); | |
| 21 | 22 | ||
@@ -79,7 +80,7 @@ function encodeFrameHybi17(payload) { | |||
| 79 | 80 | additionalLength[0] = (dataLength & 0xFF00) >> 8; | |
| 80 | 81 | additionalLength[1] = dataLength & 0xFF; | |
| 81 | 82 | } else { | |
| 82 | - additionalLength = Buffer.alloc(0); | ||
| 83 | + additionalLength = new FastBuffer(); | ||
| 83 | 84 | singleByteLength = dataLength; | |
| 84 | 85 | } | |
| 85 | 86 | ||
@@ -233,7 +234,7 @@ class Client extends EventEmitter { | |||
| 233 | 234 | this._lastId = 0; | |
| 234 | 235 | this._socket = null; | |
| 235 | 236 | this._pending = {}; | |
| 236 | - this._unprocessed = Buffer.alloc(0); | ||
| 237 | + this._unprocessed = new FastBuffer(); | ||
| 237 | 238 | } | |
| 238 | 239 | ||
| 239 | 240 | callMethod(method, params) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1605,7 +1605,7 @@ function fromList(n, state) { | |||
| 1605 | 1605 | buf[idx++] = null; | |
| 1606 | 1606 | } | |
| 1607 | 1607 | } else if (len - idx === 0) { | |
| 1608 | - ret = Buffer.alloc(0); | ||
| 1608 | + ret = new FastBuffer(); | ||
| 1609 | 1609 | } else if (len - idx === 1) { | |
| 1610 | 1610 | ret = buf[idx]; | |
| 1611 | 1611 | buf[idx++] = null; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,6 +78,7 @@ const { | |||
| 78 | 78 | kTestTimeoutFailure, | |
| 79 | 79 | Test, | |
| 80 | 80 | } = require('internal/test_runner/test'); | |
| 81 | + const { FastBuffer } = require('internal/buffer'); | ||
| 81 | 82 | ||
| 82 | 83 | const { | |
| 83 | 84 | convertStringToRegExp, | |
@@ -324,7 +325,7 @@ class FileTest extends Test { | |||
| 324 | 325 | // This method is called when it is known that there is at least one message | |
| 325 | 326 | let bufferHead = this.#rawBuffer[0]; | |
| 326 | 327 | let headerIndex = bufferHead.indexOf(v8Header); | |
| 327 | - let nonSerialized = Buffer.alloc(0); | ||
| 328 | + let nonSerialized = new FastBuffer(); | ||
| 328 | 329 | ||
| 329 | 330 | while (bufferHead && headerIndex !== 0) { | |
| 330 | 331 | const nonSerializedData = headerIndex === -1 ? | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,6 +70,7 @@ const { | |||
| 70 | 70 | validateUint32, | |
| 71 | 71 | validateFiniteNumber, | |
| 72 | 72 | } = require('internal/validators'); | |
| 73 | + const { FastBuffer } = require('internal/buffer'); | ||
| 73 | 74 | ||
| 74 | 75 | const kFlushFlag = Symbol('kFlushFlag'); | |
| 75 | 76 | const kError = Symbol('kError'); | |
@@ -150,7 +151,7 @@ function zlibBufferOnError(err) { | |||
| 150 | 151 | function zlibBufferOnEnd() { | |
| 151 | 152 | let buf; | |
| 152 | 153 | if (this.nread === 0) { | |
| 153 | - buf = Buffer.alloc(0); | ||
| 154 | + buf = new FastBuffer(); | ||
| 154 | 155 | } else { | |
| 155 | 156 | const bufs = this.buffers; | |
| 156 | 157 | buf = (bufs.length === 1 ? bufs[0] : Buffer.concat(bufs, this.nread)); | |
@@ -301,7 +302,7 @@ ZlibBase.prototype.reset = function() { | |||
| 301 | 302 | * @returns {void} | |
| 302 | 303 | */ | |
| 303 | 304 | ZlibBase.prototype._flush = function(callback) { | |
| 304 | - this._transform(Buffer.alloc(0), '', callback); | ||
| 305 | + this._transform(new FastBuffer(), '', callback); | ||
| 305 | 306 | }; | |
| 306 | 307 | ||
| 307 | 308 | /** | |
@@ -476,7 +477,7 @@ function processChunkSync(self, chunk, flushFlag) { | |||
| 476 | 477 | _close(self); | |
| 477 | 478 | ||
| 478 | 479 | if (nread === 0) | |
| 479 | - return Buffer.alloc(0); | ||
| 480 | + return new FastBuffer(); | ||
| 480 | 481 | ||
| 481 | 482 | return (buffers.length === 1 ? buffers[0] : Buffer.concat(buffers, nread)); | |
| 482 | 483 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments