summaryrefslogtreecommitdiff
path: root/ext/fetch/22_body.js
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-10-07 22:57:17 +0200
committerGitHub <noreply@github.com>2021-10-07 22:57:17 +0200
commit7e38ae17ea5dba600d0bf7bb6f6fafe7cd25befd (patch)
treecde3bb2a97fdbf19498d12e26c9f5b93814cd060 /ext/fetch/22_body.js
parent330aaae936ef9e22a3d3123402d74b416dc47be7 (diff)
perf(fetch): fast path Uint8Array in extractBody() (#12351)
Diffstat (limited to 'ext/fetch/22_body.js')
-rw-r--r--ext/fetch/22_body.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/fetch/22_body.js b/ext/fetch/22_body.js
index c9702488c..fcbce43e3 100644
--- a/ext/fetch/22_body.js
+++ b/ext/fetch/22_body.js
@@ -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(