0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-29 08:58:01 -04:00

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.
This commit is contained in:
Andreu Botella 2021-07-06 14:23:31 +02:00 committed by GitHub
parent 570309d795
commit f139a0cc11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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",
});