Skip to content

Commit 760b352

Browse files
committed
Merge pull request #105571 from marcosc90/perf-ws-onmessage
[Web] Avoid extra copy when encoding string in WebSocket `_onmessage`
2 parents b6b8c32 + f05b22c commit 760b352

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

modules/websocket/library_godot_websocket.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ const GodotWebSocket = {
5858
return;
5959
} else if (typeof event.data === 'string') {
6060
is_string = 1;
61-
const enc = new TextEncoder('utf-8');
62-
buffer = new Uint8Array(enc.encode(event.data));
61+
buffer = new TextEncoder('utf-8').encode(event.data);
6362
} else {
6463
GodotRuntime.error('Unknown message type');
6564
return;

0 commit comments

Comments
 (0)