| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e6b3bfe commit cf071a0
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -250,7 +250,8 @@ function readableAddChunk(stream, chunk, encoding, addToFront) { | |||
| 250 | 250 | } else if (state.objectMode || chunk && chunk.length > 0) { | |
| 251 | 251 | if (typeof chunk !== 'string' && | |
| 252 | 252 | !state.objectMode && | |
| 253 | - Object.getPrototypeOf(chunk) !== Buffer.prototype) { | ||
| 253 | + // Do not use Object.getPrototypeOf as it is slower since V8 7.3. | ||
| 254 | + !(chunk instanceof Buffer)) { | ||
| 254 | 255 | chunk = Stream._uint8ArrayToBuffer(chunk); | |
| 255 | 256 | } | |
| 256 | 257 | ||
@@ -393,7 +394,13 @@ function howMuchToRead(n, state) { | |||
| 393 | 394 | // You can override either this method, or the async _read(n) below. | |
| 394 | 395 | Readable.prototype.read = function(n) { | |
| 395 | 396 | debug('read', n); | |
| 396 | - n = parseInt(n, 10); | ||
| 397 | + // Same as parseInt(undefined, 10), however V8 7.3 performance regressed | ||
| 398 | + // in this scenario, so we are doing it manually. | ||
| 399 | + if (n === undefined) { | ||
| 400 | + n = NaN; | ||
| 401 | + } else if (!Number.isInteger(n)) { | ||
| 402 | + n = parseInt(n, 10); | ||
| 403 | + } | ||
| 397 | 404 | const state = this._readableState; | |
| 398 | 405 | const nOrig = n; | |
| 399 | 406 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -277,7 +277,8 @@ Writable.prototype.write = function(chunk, encoding, cb) { | |||
| 277 | 277 | var ret = false; | |
| 278 | 278 | const isBuf = !state.objectMode && Stream._isUint8Array(chunk); | |
| 279 | 279 | ||
| 280 | - if (isBuf && Object.getPrototypeOf(chunk) !== Buffer.prototype) { | ||
| 280 | + // Do not use Object.getPrototypeOf as it is slower since V8 7.3. | ||
| 281 | + if (isBuf && !(chunk instanceof Buffer)) { | ||
| 281 | 282 | chunk = Stream._uint8ArrayToBuffer(chunk); | |
| 282 | 283 | } | |
| 283 | 284 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments