diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2022-08-19 15:54:40 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-19 15:54:40 +0530 |
commit | 9e576dff7c39cfd510c60ba92aa0d1c15fd24a6b (patch) | |
tree | 963c9805db09bf1a93c0548956f858918250821e /ext/web/06_streams.js | |
parent | 8bdcec1c84636aa00bf7444539e68b49d79b1fbf (diff) |
perf(runtime): optimize Deno.file open & stream (#15496)
Diffstat (limited to 'ext/web/06_streams.js')
-rw-r--r-- | ext/web/06_streams.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 1b753572b..bd1714964 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -658,7 +658,9 @@ * @returns {ReadableStream<Uint8Array>} */ function readableStreamForRid(rid, unrefCallback) { - const stream = new ReadableStream({ + const stream = webidl.createBranded(ReadableStream); + stream[_maybeRid] = rid; + const underlyingSource = { type: "bytes", async pull(controller) { const v = controller.byobRequest.view; @@ -685,9 +687,15 @@ core.tryClose(rid); }, autoAllocateChunkSize: DEFAULT_CHUNK_SIZE, - }); + }; + initializeReadableStream(stream); + setUpReadableByteStreamControllerFromUnderlyingSource( + stream, + underlyingSource, + underlyingSource, + 0, + ); - stream[_maybeRid] = rid; return stream; } @@ -714,7 +722,6 @@ } return true; } - /** * @template T * @param {{ [_queue]: Array<ValueWithSize<T | _close>>, [_queueTotalSize]: number }} container |