mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05: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:
parent
570309d795
commit
f139a0cc11
1 changed files with 6 additions and 2 deletions
|
@ -141,7 +141,9 @@
|
||||||
encode(input = "") {
|
encode(input = "") {
|
||||||
webidl.assertBranded(this, TextEncoder);
|
webidl.assertBranded(this, TextEncoder);
|
||||||
const prefix = "Failed to execute 'encode' on '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,
|
prefix,
|
||||||
context: "Argument 1",
|
context: "Argument 1",
|
||||||
});
|
});
|
||||||
|
@ -156,7 +158,9 @@
|
||||||
encodeInto(source, destination) {
|
encodeInto(source, destination) {
|
||||||
webidl.assertBranded(this, TextEncoder);
|
webidl.assertBranded(this, TextEncoder);
|
||||||
const prefix = "Failed to execute 'encodeInto' on '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,
|
prefix,
|
||||||
context: "Argument 1",
|
context: "Argument 1",
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue