PerformScan: Reorganise config loop early-exits
Keep them contiguous at the top as much as possible.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I3f7ab1529c2c39c98dd6e4a887c8e86d261367f4
diff --git a/src/PerformScan.cpp b/src/PerformScan.cpp
index 5c00bf6..1c71267 100644
--- a/src/PerformScan.cpp
+++ b/src/PerformScan.cpp
@@ -471,27 +471,16 @@
for (auto it = _configurations.begin(); it != _configurations.end();)
{
- auto findProbe = it->find("Probe");
- auto findName = it->find("Name");
-
- nlohmann::json probeCommand;
// check for poorly formatted fields, probe must be an array
+ auto findProbe = it->find("Probe");
if (findProbe == it->end())
{
std::cerr << "configuration file missing probe:\n " << *it << "\n";
it = _configurations.erase(it);
continue;
}
- if ((*findProbe).type() != nlohmann::json::value_t::array)
- {
- probeCommand = nlohmann::json::array();
- probeCommand.push_back(*findProbe);
- }
- else
- {
- probeCommand = *findProbe;
- }
+ auto findName = it->find("Name");
if (findName == it->end())
{
std::cerr << "configuration file missing name:\n " << *it << "\n";
@@ -506,7 +495,18 @@
it = _configurations.erase(it);
continue;
}
+
nlohmann::json* recordPtr = &(*it);
+ nlohmann::json probeCommand;
+ if ((*findProbe).type() != nlohmann::json::value_t::array)
+ {
+ probeCommand = nlohmann::json::array();
+ probeCommand.push_back(*findProbe);
+ }
+ else
+ {
+ probeCommand = *findProbe;
+ }
// store reference to this to children to makes sure we don't get
// destroyed too early