From 5fe660ecd76fe164c2065bea00fbba49d39553c2 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sat, 17 Sep 2022 16:48:15 +0530 Subject: perf(web): optimize encodeInto() (#15922) --- ext/web/08_text_encoding.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'ext/web/08_text_encoding.js') diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js index 9e0c1f311..db724033f 100644 --- a/ext/web/08_text_encoding.js +++ b/ext/web/08_text_encoding.js @@ -25,6 +25,7 @@ TypedArrayPrototypeSubarray, TypedArrayPrototypeSlice, Uint8Array, + Uint32Array, } = window.__bootstrap.primordials; class TextDecoder { @@ -199,10 +200,16 @@ context: "Argument 2", allowShared: true, }); - return ops.op_encoding_encode_into(source, destination); + ops.op_encoding_encode_into(source, destination, encodeIntoBuf); + return { + read: encodeIntoBuf[0], + written: encodeIntoBuf[1], + }; } } + const encodeIntoBuf = new Uint32Array(2); + webidl.configurePrototype(TextEncoder); const TextEncoderPrototype = TextEncoder.prototype; -- cgit v1.2.3