Ver Fonte

Merge pull request #105571 from marcosc90/perf-ws-onmessage

[Web] Avoid extra copy when encoding string in WebSocket `_onmessage`
Thaddeus Crews há 3 meses atrás
pai
commit
760b3522d7
1 ficheiros alterados com 1 adições e 2 exclusões
  1. 1 2
      modules/websocket/library_godot_websocket.js

+ 1 - 2
modules/websocket/library_godot_websocket.js

@@ -58,8 +58,7 @@ const GodotWebSocket = {
 				return;
 			} else if (typeof event.data === 'string') {
 				is_string = 1;
-				const enc = new TextEncoder('utf-8');
-				buffer = new Uint8Array(enc.encode(event.data));
+				buffer = new TextEncoder('utf-8').encode(event.data);
 			} else {
 				GodotRuntime.error('Unknown message type');
 				return;