aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/streams.exports.js
diff options
context:
space:
mode:
authorGravatar Alex Lam S.L <alexlamsl@gmail.com> 2023-01-04 02:08:28 +0200
committerGravatar GitHub <noreply@github.com> 2023-01-03 16:08:28 -0800
commit237bcdf99f5c8b2431e89bc9fa6300a7d256e7eb (patch)
tree653da17ab736d063efd69b12418551f76e9c6cfa /src/bun.js/streams.exports.js
parent0b395ca1dca8432d04a65402b1d666d6b36ce4ae (diff)
downloadbun-237bcdf99f5c8b2431e89bc9fa6300a7d256e7eb.tar.gz
bun-237bcdf99f5c8b2431e89bc9fa6300a7d256e7eb.tar.zst
bun-237bcdf99f5c8b2431e89bc9fa6300a7d256e7eb.zip
[streams] speed up `Readable` in some cases (#1708)
If `encoding` is set, no `Buffer`s would be exposed thus `Uint8Array` can be used directly. - fix data corruption in `BufferList.concat()` - fix segfaults in `BufferList.join()`
Diffstat (limited to 'src/bun.js/streams.exports.js')
-rw-r--r--src/bun.js/streams.exports.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bun.js/streams.exports.js b/src/bun.js/streams.exports.js
index 988666388..5df244950 100644
--- a/src/bun.js/streams.exports.js
+++ b/src/bun.js/streams.exports.js
@@ -2949,7 +2949,9 @@ var require_readable = __commonJS({
} else if (chunk instanceof Buffer) {
encoding = "";
} else if (Stream._isUint8Array(chunk)) {
- chunk = Stream._uint8ArrayToBuffer(chunk);
+ if (addToFront || !state.decoder) {
+ chunk = Stream._uint8ArrayToBuffer(chunk);
+ }
encoding = "";
} else if (chunk != null) {
err = new ERR_INVALID_ARG_TYPE(