From 112664f42ff2fe873c24182f9b96b06277212bec Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Wed, 5 Oct 2022 18:37:34 +0200 Subject: [PATCH] Simplify inverterEdit method Replaced for loop with unused variable by .size() method --- src/WebApi_inverter.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/WebApi_inverter.cpp b/src/WebApi_inverter.cpp index 06db1c21..12cadaf0 100644 --- a/src/WebApi_inverter.cpp +++ b/src/WebApi_inverter.cpp @@ -210,11 +210,7 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request) } JsonArray maxPowerArray = root[F("max_power")].as(); - uint8_t arrayCount = 0; - for (JsonVariant maxPower : maxPowerArray) { - arrayCount++; - } - if (arrayCount != INV_MAX_CHAN_COUNT) { + if (maxPowerArray.size() != INV_MAX_CHAN_COUNT) { retMsg[F("message")] = F("Invalid amount of max channel setting given!"); response->setLength(); request->send(response); @@ -230,7 +226,7 @@ void WebApiInverterClass::onInverterEdit(AsyncWebServerRequest* request) inverter.Serial = new_serial; strncpy(inverter.Name, root[F("name")].as().c_str(), INV_MAX_NAME_STRLEN); - arrayCount = 0; + uint8_t arrayCount = 0; for (JsonVariant maxPower : maxPowerArray) { inverter.MaxChannelPower[arrayCount] = maxPower.as(); arrayCount++;