EntityManager: Exploit destructuring for device removed loop
This makes the code a bit nicer to read.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Icea51f4841e316c0ba259cf6c104e3e449bb4dbe
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index 5ec5cfa..f8144b3 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -882,14 +882,14 @@
}
bool powerOff = !isPowerOn();
- for (const auto& item : lastJson.items())
+ for (const auto& [name, device] : lastJson.items())
{
- if (systemConfiguration.contains(item.key()))
+ if (systemConfiguration.contains(name))
{
continue;
}
- bool requirePowerOn = deviceRequiresPowerOn(item.value());
+ bool requirePowerOn = deviceRequiresPowerOn(device);
if (powerOff && requirePowerOn)
{
// power not on yet, don't know if it's there or not
@@ -901,7 +901,7 @@
continue;
}
- logDeviceRemoved(item.value());
+ logDeviceRemoved(device);
}
scannedPowerOff = true;
if (!powerOff)