PerformScan: Extract pruneRecordExposes()

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I95b56e7a1c1c3733e1d98501f5d3076da56a91f4
diff --git a/src/PerformScan.cpp b/src/PerformScan.cpp
index eee185a..e26ca5e 100644
--- a/src/PerformScan.cpp
+++ b/src/PerformScan.cpp
@@ -243,6 +243,25 @@
     _configurations(configurations), objServer(objServerIn),
     _callback(std::move(callback))
 {}
+
+static void pruneRecordExposes(nlohmann::json& fromLastJson)
+{
+    auto findExposes = fromLastJson.find("Exposes");
+    if (findExposes != fromLastJson.end())
+    {
+        auto copy = nlohmann::json::array();
+        for (auto& expose : *findExposes)
+        {
+            if (expose.is_null())
+            {
+                continue;
+            }
+            copy.emplace_back(expose);
+        }
+        *findExposes = copy;
+    }
+}
+
 void PerformScan::run()
 {
     boost::container::flat_set<std::string> dbusProbeInterfaces;
@@ -315,21 +334,7 @@
                     auto fromLastJson = lastJson.find(recordName);
                     if (fromLastJson != lastJson.end())
                     {
-                        auto findExposes = fromLastJson->find("Exposes");
-                        // delete nulls from any updates
-                        if (findExposes != fromLastJson->end())
-                        {
-                            auto copy = nlohmann::json::array();
-                            for (auto& expose : *findExposes)
-                            {
-                                if (expose.is_null())
-                                {
-                                    continue;
-                                }
-                                copy.emplace_back(expose);
-                            }
-                            *findExposes = copy;
-                        }
+                        pruneRecordExposes(*fromLastJson);
 
                         // keep user changes
                         _systemConfiguration[recordName] = *fromLastJson;