diff options
author | Andreu Botella <abb@randomunok.com> | 2021-07-06 14:23:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-06 14:23:31 +0200 |
commit | f139a0cc11f0b3a7e3cb1975310c079e4741d199 (patch) | |
tree | 95e4125b671a0a45bb940b3ebc5d528c0816a7a3 /extensions/web/08_text_encoding.js | |
parent | 570309d795d2e2a00fc2523ca80818b275b567e6 (diff) |
perf: don't double convert to USVString for TextEncoder (#11297)
This works since both core.encode and the ops bindings to a Rust String
will already replace any lone surrogates with the replacement character.
Diffstat (limited to 'extensions/web/08_text_encoding.js')
-rw-r--r-- | extensions/web/08_text_encoding.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/extensions/web/08_text_encoding.js b/extensions/web/08_text_encoding.js index 0ba1bb582..0918cee64 100644 --- a/extensions/web/08_text_encoding.js +++ b/extensions/web/08_text_encoding.js @@ -141,7 +141,9 @@ encode(input = "") { webidl.assertBranded(this, TextEncoder); const prefix = "Failed to execute 'encode' on 'TextEncoder'"; - input = webidl.converters.USVString(input, { + // The WebIDL type of `input` is `USVString`, but `core.encode` already + // converts lone surrogates to the replacement character. + input = webidl.converters.DOMString(input, { prefix, context: "Argument 1", }); @@ -156,7 +158,9 @@ encodeInto(source, destination) { webidl.assertBranded(this, TextEncoder); const prefix = "Failed to execute 'encodeInto' on 'TextEncoder'"; - source = webidl.converters.USVString(source, { + // The WebIDL type of `source` is `USVString`, but the ops bindings + // already convert lone surrogates to the replacement character. + source = webidl.converters.DOMString(source, { prefix, context: "Argument 1", }); |