mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
perf(ext/fetch): speed up resp.clone()
(#24812)
(cherry picked from commit b153065e44
)
This commit is contained in:
parent
e23512fde3
commit
f8a9d8defc
1 changed files with 17 additions and 4 deletions
|
@ -196,10 +196,23 @@ class InnerBody {
|
||||||
* @returns {InnerBody}
|
* @returns {InnerBody}
|
||||||
*/
|
*/
|
||||||
clone() {
|
clone() {
|
||||||
const { 0: out1, 1: out2 } = readableStreamTee(this.stream, true);
|
let second;
|
||||||
this.streamOrStatic = out1;
|
if (
|
||||||
const second = new InnerBody(out2);
|
!ObjectPrototypeIsPrototypeOf(
|
||||||
second.source = core.deserialize(core.serialize(this.source));
|
ReadableStreamPrototype,
|
||||||
|
this.streamOrStatic,
|
||||||
|
) && !this.streamOrStatic.consumed
|
||||||
|
) {
|
||||||
|
second = new InnerBody({
|
||||||
|
body: this.streamOrStatic.body,
|
||||||
|
consumed: false,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const { 0: out1, 1: out2 } = readableStreamTee(this.stream, true);
|
||||||
|
this.streamOrStatic = out1;
|
||||||
|
second = new InnerBody(out2);
|
||||||
|
}
|
||||||
|
second.source = this.source;
|
||||||
second.length = this.length;
|
second.length = this.length;
|
||||||
return second;
|
return second;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue