mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Optimize JsonArray itteration
This commit is contained in:
parent
3d2763e5de
commit
47cce5f0cd
@ -84,7 +84,7 @@ void dispatchJson(String & strPayload)
|
|||||||
strPayload.remove(strPayload.length() - 2, 2);
|
strPayload.remove(strPayload.length() - 2, 2);
|
||||||
strPayload.concat("]");
|
strPayload.concat("]");
|
||||||
}
|
}
|
||||||
DynamicJsonDocument haspCommands(2048 + 1024);
|
DynamicJsonDocument haspCommands(2048 + 512);
|
||||||
DeserializationError jsonError = deserializeJson(haspCommands, strPayload);
|
DeserializationError jsonError = deserializeJson(haspCommands, strPayload);
|
||||||
if(jsonError) { // Couldn't parse incoming JSON command
|
if(jsonError) { // Couldn't parse incoming JSON command
|
||||||
errorPrintln(String(F("JSON: %sFailed to parse incoming JSON command with error: ")) +
|
errorPrintln(String(F("JSON: %sFailed to parse incoming JSON command with error: ")) +
|
||||||
@ -92,8 +92,16 @@ void dispatchJson(String & strPayload)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint8_t i = 0; i < haspCommands.size(); i++) {
|
// Slow
|
||||||
dispatchCommand(haspCommands[i]);
|
// for(uint8_t i = 0; i < haspCommands.size(); i++) {
|
||||||
|
// dispatchCommand(haspCommands[i]);
|
||||||
|
//}
|
||||||
|
|
||||||
|
// Get a reference to the root array
|
||||||
|
JsonArray arr = haspCommands.as<JsonArray>();
|
||||||
|
// Fast
|
||||||
|
for(JsonVariant command : arr) {
|
||||||
|
dispatchCommand(command.as<String>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user