Skip to content

Commit 5c23d80

Browse files
committed
refactor RemoveIncompatibilities to improve iteration and const correctness
1 parent 3e626e7 commit 5c23d80

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

compatibility/compatibility.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ namespace compatibility
6060

6161
void RemoveIncompatibilities(nlohmann::json& json)
6262
{
63-
for (auto jsonIter = json.begin(); jsonIter != json.end();)
63+
64+
for (auto jsonIter = json.begin(); jsonIter != json.end(); ++jsonIter)
6465
{
65-
auto& key = jsonIter.key();
66+
const auto& key = jsonIter.key();
6667
auto& value = jsonIter.value();
6768

6869
if (key == "exception")
@@ -76,7 +77,6 @@ namespace compatibility
7677
else if (value.is_object())
7778
{
7879
RemoveIncompatibilities(value);
79-
++jsonIter;
8080
}
8181
else if (value.is_array())
8282
{
@@ -90,8 +90,6 @@ namespace compatibility
9090

9191
++valueIter;
9292
}
93-
94-
++jsonIter;
9593
}
9694
else if (key == "data")
9795
{
@@ -105,11 +103,7 @@ namespace compatibility
105103
uri = std::regex_replace(uri, std::regex(R"(\.ts$)"), ".cpp");
106104

107105
json[key] = std::filesystem::canonical(uri).string();
108-
109-
++jsonIter;
110106
}
111-
else
112-
++jsonIter;
113107
}
114108
}
115109

0 commit comments

Comments
 (0)