From 85fe6ada8b92fcd2ff9397b5059d6bf5f0111ffb Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Tue, 22 Aug 2023 19:06:25 -0300 Subject: [PATCH] Parse vehicle parameter table once 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. --- src/stores/mainVehicle.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stores/mainVehicle.ts b/src/stores/mainVehicle.ts index 3b7a0d5fc..35ea655fe 100644 --- a/src/stores/mainVehicle.ts +++ b/src/stores/mainVehicle.ts @@ -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() })