Skip to content

Commit

Permalink
Parse vehicle parameter table once
Browse files Browse the repository at this point in the history
With the previous implementation, the reactive property of the store was updated hundred of times on the initial parsing, leading to a performance bottleneck.
The new implementation parse the entire metadata and then assign it to the reactive property, so it prevents unnecessary reactive calculations.
  • Loading branch information
rafaellehmkuhl committed Aug 22, 2023
1 parent 8ecfaa7 commit 85fe6ad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/stores/mainVehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,17 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
metadata = ardurover_metadata
}

const updatedParameterTable = {}
for (const category of Object.values(metadata)) {
for (const [name, parameter] of Object.entries(category)) {
if (!isNaN(Number(parameter))) {
continue
}
const newParameterTable = { ...parametersTable, ...{ [name]: parameter } }
Object.assign(parametersTable, newParameterTable)
Object.assign(updatedParameterTable, newParameterTable)
}
}
Object.assign(parametersTable, updatedParameterTable)
}
requestParametersList()
})
Expand Down

0 comments on commit 85fe6ad

Please sign in to comment.