From 697b60a335cad20f73e568c47d17564a6bd3fab7 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 16 Mar 2022 12:58:38 +0530 Subject: [PATCH] perf(web): use DOMString for BlobParts (#13979) --- cli/bench/deno_common.js | 8 ++++++++ ext/web/09_file.js | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cli/bench/deno_common.js b/cli/bench/deno_common.js index 71195b32ea..629ed7669a 100644 --- a/cli/bench/deno_common.js +++ b/cli/bench/deno_common.js @@ -56,6 +56,13 @@ function benchUrlParse() { }); } +function benchLargeBlobText() { + const input = "long-string".repeat(999_999); + benchSync("blob_text_large", 3, () => { + new Blob([input]).text(); + }); +} + function benchDateNow() { benchSync("date_now", 5e5, () => { Date.now(); @@ -123,6 +130,7 @@ async function main() { // A common "language feature", that should be fast // also a decent representation of a non-trivial JSON-op benchUrlParse(); + benchLargeBlobText(); benchB64RtLong(); benchB64RtShort(); // IO ops diff --git a/ext/web/09_file.js b/ext/web/09_file.js index fbc00326ef..2117a0835e 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -394,7 +394,10 @@ return webidl.converters["ArrayBufferView"](V, opts); } } - return webidl.converters["USVString"](V, opts); + // BlobPart is passed to processBlobParts after conversion, which calls core.encode() + // on the string. + // core.encode() is equivalent to USVString normalization. + return webidl.converters["DOMString"](V, opts); }; webidl.converters["sequence"] = webidl.createSequenceConverter( webidl.converters["BlobPart"],