1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

perf(fetch): fast path Uint8Array in extractBody() (#12351)

This commit is contained in:
Aaron O'Mullan 2021-10-07 22:57:17 +02:00 committed by GitHub
parent 330aaae936
commit 7e38ae17ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -331,6 +331,10 @@
if (object.type.length !== 0) {
contentType = object.type;
}
} else if (object instanceof Uint8Array) {
// Fast(er) path for common case of Uint8Array
const copy = TypedArrayPrototypeSlice(object, 0, object.byteLength);
source = copy;
} else if (ArrayBufferIsView(object) || object instanceof ArrayBuffer) {
const u8 = ArrayBufferIsView(object)
? new Uint8Array(