Merge pull request #104433 from marcosc90/perf-wasm-ws

[Web] Optimize WebSocket send by replacing per-byte heap reads with heapSlice
This commit is contained in:
Thaddeus Crews 2026-01-28 12:27:14 -06:00
commit 3c341ffcab
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC

View file

@ -169,14 +169,9 @@ const GodotWebSocket = {
godot_js_websocket_send__proxy: 'sync',
godot_js_websocket_send__sig: 'iiiii',
godot_js_websocket_send: function (p_id, p_buf, p_buf_len, p_raw) {
const bytes_array = new Uint8Array(p_buf_len);
let i = 0;
for (i = 0; i < p_buf_len; i++) {
bytes_array[i] = GodotRuntime.getHeapValue(p_buf + i, 'i8');
}
let out = bytes_array.buffer;
let out = GodotRuntime.heapSlice(HEAPU8, p_buf, p_buf_len);
if (!p_raw) {
out = new TextDecoder('utf-8').decode(bytes_array);
out = new TextDecoder('utf-8').decode(out);
}
return GodotWebSocket.send(p_id, out);
},