Skip to content

Commit 99986ea

Browse files
committed
perf: cache keyboard codes to optimize getKeyboardCode performance by avoiding repeated config parsing.
1 parent 2f7f489 commit 99986ea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/classes/emulator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class Emulator {
4848
private blobUrlJs: string | undefined
4949
private blobUrlWasm: string | undefined
5050

51+
private cachedKeyboardCodes: Map<string, string> | null = null
5152
private canvasInitialSize = { height: 0, width: 0 }
5253
private emscripten: EmulatorEmscripten | undefined
5354
private eventListeners: Record<EmulatorEvent, ((...args: unknown[]) => unknown)[]> = {
@@ -57,7 +58,7 @@ export class Emulator {
5758
private fileSystem: EmulatorFileSystem | undefined
5859
private gameStatus: GameStatus = 'initial'
5960
private globalDOMEventListeners = new Map<EventTarget, Record<string, EventListenerOrEventListenerObject>>()
60-
private cachedKeyboardCodes: Map<string, string> | null = null
61+
6162
private messageQueue: [Uint8Array, number][] = []
6263

6364
private options: EmulatorOptions

0 commit comments

Comments
 (0)