From 2a2dff6202da5ef4fed802f21c569bb17738f8d6 Mon Sep 17 00:00:00 2001 From: Ross Andrews Date: Sat, 27 Apr 2024 23:57:22 -0500 Subject: [PATCH] Don't recreate the CPU each render --- vweb/src/snippet_emulator.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vweb/src/snippet_emulator.jsx b/vweb/src/snippet_emulator.jsx index 5db3f0c..29c4257 100644 --- a/vweb/src/snippet_emulator.jsx +++ b/vweb/src/snippet_emulator.jsx @@ -22,7 +22,7 @@ export default function({ children, width = 80 }) { const onChangeSrc = useCallback((e) => setSrc(e.target.value), []) // Callback for the textarea const [binary, setBinary] = useState(null) // The assembled binary const [sourceMap, setSourceMap] = useState(null) // A map from byte address to line number - const [cpu, _setCpu] = useState(new WasmCPU()) // The actual CPU emulator itself + const [cpu, _setCpu] = useState(() => new WasmCPU()) // The actual CPU emulator itself const [activeLine, setActiveLine] = useState(null) // The (0-based) index of the // Update which line is highlighted. This should be called in most button callbacks.