PerformScan: Untemplated record name allows early continue
Continuing early in the loop reduces indentation.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ife17dbe9ab437e4779e86c3f75b4a1edd02ba051
diff --git a/src/PerformScan.cpp b/src/PerformScan.cpp
index 777b78f..c4acf5b 100644
--- a/src/PerformScan.cpp
+++ b/src/PerformScan.cpp
@@ -349,32 +349,36 @@
// iterator
itr = foundDevices.erase(itr);
- if (hasTemplateName)
+ if (!hasTemplateName)
{
- auto nameIt = fromLastJson->find("Name");
- if (nameIt == fromLastJson->end())
- {
- std::cerr << "Last JSON Illegal\n";
- continue;
- }
- int index = 0;
- auto str = nameIt->get<std::string>().substr(indexIdx);
- auto [p, ec] = std::from_chars(
- str.data(), str.data() + str.size(), index);
- if (ec != std::errc())
- {
- continue; // non-numeric replacement
- }
- usedNames.insert(nameIt.value());
- auto usedIt =
- std::find(indexes.begin(), indexes.end(), index);
-
- if (usedIt == indexes.end())
- {
- continue; // less items now
- }
- indexes.erase(usedIt);
+ continue;
}
+
+ auto nameIt = fromLastJson->find("Name");
+ if (nameIt == fromLastJson->end())
+ {
+ std::cerr << "Last JSON Illegal\n";
+ continue;
+ }
+
+ int index = 0;
+ auto str = nameIt->get<std::string>().substr(indexIdx);
+ auto [p, ec] = std::from_chars(
+ str.data(), str.data() + str.size(), index);
+ if (ec != std::errc())
+ {
+ continue; // non-numeric replacement
+ }
+
+ usedNames.insert(nameIt.value());
+ auto usedIt =
+ std::find(indexes.begin(), indexes.end(), index);
+
+ if (usedIt == indexes.end())
+ {
+ continue; // less items now
+ }
+ indexes.erase(usedIt);
}
std::optional<std::string> replaceStr;