EntityManager: Introduce getDeviceInterfaces()

Drop some noise from the loop in propertiesChangedCallback().

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ib4b4496aa82cd3cbe46b68dd86cf88f7f2b83d97
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index c0c79aa..3b89e96 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -912,6 +912,12 @@
         });
 }
 
+static std::vector<std::weak_ptr<sdbusplus::asio::dbus_interface>>&
+    getDeviceInterfaces(const nlohmann::json& device)
+{
+    return inventory[device["Name"].get<std::string>()];
+}
+
 // main properties changed entry
 void propertiesChangedCallback(nlohmann::json& systemConfiguration,
                                sdbusplus::asio::object_server& objServer)
@@ -972,9 +978,7 @@
                         // power not on yet, don't know if it's there or not
                         continue;
                     }
-                    std::string name = item.value()["Name"].get<std::string>();
-                    std::vector<std::weak_ptr<sdbusplus::asio::dbus_interface>>&
-                        ifaces = inventory[name];
+                    auto& ifaces = getDeviceInterfaces(item.value());
                     for (auto& iface : ifaces)
                     {
                         auto sharedPtr = iface.lock();