Skip to content

Commit

Permalink
perf(assembler): pre-freeze big object
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Dec 14, 2023
1 parent 424c380 commit 085caf6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/features/assembler/assemble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export const assemble = (input: string): void => {
store.dispatch(resetMemoryData())
store.dispatch(clearEditorHighlightRange())
}
const [addressToOpcodeMap, addressToStatementMap] = assembleResult
const [addressToCodeMap, addressToStatementMap] = assembleResult
store.dispatch(setAssemblerState({ source: input, addressToStatementMap }))
store.dispatch(setMemoryDataFrom(addressToOpcodeMap))
store.dispatch(setMemoryDataFrom(addressToCodeMap))
// TODO: move to viewEffects: `store.onAction(setAssemblerState)`
const firstStatement = addressToStatementMap[0]
const hasStatement = firstStatement !== undefined
if (hasStatement) {
if (firstStatement) {
store.dispatch(setEditorHighlightRange(firstStatement))
}
}
2 changes: 1 addition & 1 deletion src/features/assembler/assemblerSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const assemblerSlice = createSlice({
) => {
state.error = null
state.source = action.payload.source
state.addressToStatementMap = action.payload.addressToStatementMap
state.addressToStatementMap = Object.freeze(action.payload.addressToStatementMap)
},
setError: (state, action: PayloadAction<AssemblerErrorObject>) => {
state.error = action.payload
Expand Down

0 comments on commit 085caf6

Please sign in to comment.