mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 16:57:22 +00:00
Merge pull request #132 from devcat/zlib-zero-copy
change to zlib zero-copy inflate
This commit is contained in:
@@ -7,4 +7,4 @@ export {
|
||||
isWebSocketPongEvent,
|
||||
} from "https://deno.land/std@0.67.0/ws/mod.ts";
|
||||
export type { WebSocket } from "https://deno.land/std@0.67.0/ws/mod.ts";
|
||||
export { decompress as inflate } from "https://unpkg.com/@evan/wasm@0.0.9/target/zlib/deno.js";
|
||||
export { decompress_with as inflate } from "https://unpkg.com/@evan/wasm@0.0.11/target/zlib/deno.js";
|
||||
|
||||
@@ -24,6 +24,7 @@ import { handleDiscordPayload } from "./shardingManager.ts";
|
||||
|
||||
const basicShards = new Map<number, BasicShard>();
|
||||
const heartbeating = new Set<number>();
|
||||
const utf8decoder = new TextDecoder();
|
||||
|
||||
export interface BasicShard {
|
||||
id: number;
|
||||
@@ -109,7 +110,11 @@ export async function createBasicShard(
|
||||
}
|
||||
|
||||
if (message instanceof Uint8Array) {
|
||||
message = new TextDecoder().decode(inflate(message, 0));
|
||||
message = inflate(
|
||||
message,
|
||||
0,
|
||||
(slice: Uint8Array) => utf8decoder.decode(slice),
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof message === "string") {
|
||||
|
||||
Reference in New Issue
Block a user