EntityManager: Extract deriveNewConfiguration()
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Id9ad4739aa1672bd33e0799785aa1d5ed3360b5d
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index e8113c2..cd748df 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -944,6 +944,23 @@
logDeviceRemoved(device);
}
+static void deriveNewConfiguration(const nlohmann::json& oldConfiguration,
+ nlohmann::json& newConfiguration)
+{
+ for (auto it = newConfiguration.begin(); it != newConfiguration.end();)
+ {
+ auto findKey = oldConfiguration.find(it.key());
+ if (findKey != oldConfiguration.end())
+ {
+ it = newConfiguration.erase(it);
+ }
+ else
+ {
+ it++;
+ }
+ }
+}
+
// main properties changed entry
void propertiesChangedCallback(nlohmann::json& systemConfiguration,
sdbusplus::asio::object_server& objServer)
@@ -1005,19 +1022,9 @@
}
nlohmann::json newConfiguration = systemConfiguration;
- for (auto it = newConfiguration.begin();
- it != newConfiguration.end();)
- {
- auto findKey = oldConfiguration.find(it.key());
- if (findKey != oldConfiguration.end())
- {
- it = newConfiguration.erase(it);
- }
- else
- {
- it++;
- }
- }
+
+ deriveNewConfiguration(oldConfiguration, newConfiguration);
+
for (const auto& [_, device] : newConfiguration.items())
{
logDeviceAdded(device);