mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:47:03 +08:00
refactor: Fix clang-tidy modernize-loop-convert
This commit is contained in:
@@ -13,9 +13,9 @@ namespace swift::misc::aviation
|
||||
CAircraftEngineList::CAircraftEngineList(std::initializer_list<bool> enginesOnOff)
|
||||
{
|
||||
int no = 1; // engines 1 based
|
||||
for (auto it = enginesOnOff.begin(); it != enginesOnOff.end(); ++it)
|
||||
for (bool it : enginesOnOff)
|
||||
{
|
||||
CAircraftEngine engine(no++, *it);
|
||||
CAircraftEngine engine(no++, it);
|
||||
this->push_back(engine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,11 +136,10 @@ namespace swift::misc
|
||||
if (value.isUndefined()) { throw CJsonException("Missing 'containerbase'"); }
|
||||
QJsonArray array = value.toArray();
|
||||
int index = 0;
|
||||
for (auto i = array.begin(); i != array.end(); ++i)
|
||||
for (auto ref : array)
|
||||
{
|
||||
CJsonScope scope("containerbase", index++);
|
||||
Q_UNUSED(scope);
|
||||
QJsonValueRef ref = (*i);
|
||||
typename Derived::value_type val;
|
||||
ref >> val;
|
||||
derived().push_back(std::move(val));
|
||||
|
||||
@@ -763,14 +763,14 @@ namespace swift::misc
|
||||
QJsonArray CDataCacheRevision::toJson(const QSet<QString> &pins)
|
||||
{
|
||||
QJsonArray result;
|
||||
for (auto it = pins.begin(); it != pins.end(); ++it) { result.push_back(*it); }
|
||||
for (const auto &pin : pins) { result.push_back(pin); }
|
||||
return result;
|
||||
}
|
||||
|
||||
QSet<QString> CDataCacheRevision::fromJson(const QJsonArray &pins)
|
||||
{
|
||||
QSet<QString> result;
|
||||
for (auto it = pins.begin(); it != pins.end(); ++it) { result.insert(it->toString()); }
|
||||
for (auto pin : pins) { result.insert(pin.toString()); }
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -639,10 +639,10 @@ namespace swift::misc::json
|
||||
{
|
||||
QStringList sl;
|
||||
if (array.isEmpty()) { return sl; }
|
||||
for (int i = 0; i < array.size(); i++)
|
||||
for (const auto &i : array)
|
||||
{
|
||||
if (!array.at(i).isString()) { continue; }
|
||||
sl.push_back(array.at(i).toString());
|
||||
if (!i.isString()) { continue; }
|
||||
sl.push_back(i.toString());
|
||||
}
|
||||
return sl;
|
||||
}
|
||||
|
||||
@@ -1507,7 +1507,7 @@ namespace swift::misc::simulation
|
||||
{
|
||||
CAircraftModel::MemoHelper::CMemoizer helper;
|
||||
QJsonArray array;
|
||||
for (auto it = cbegin(); it != cend(); ++it) { array << it->toMemoizedJson(helper); }
|
||||
for (const auto &it : *this) { array << it.toMemoizedJson(helper); }
|
||||
QJsonObject json;
|
||||
json.insert("containerbase", array);
|
||||
json.insert("aircraftIcaos", helper.getTable<CAircraftIcaoCode>().toJson());
|
||||
@@ -1563,12 +1563,12 @@ namespace swift::misc::simulation
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (auto i = array.begin(); i != array.end(); ++i)
|
||||
for (auto &&i : array)
|
||||
{
|
||||
CJsonScope scope("containerbase", index++);
|
||||
Q_UNUSED(scope)
|
||||
CAircraftModel value;
|
||||
value.convertFromMemoizedJson(i->toObject(), helper);
|
||||
value.convertFromMemoizedJson(i.toObject(), helper);
|
||||
this->push_back(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,20 +295,14 @@ namespace swift::misc::simulation
|
||||
|
||||
bool CInterpolatorSpline::areAnyElevationsMissing() const
|
||||
{
|
||||
for (unsigned int i = 0; i < m_s.size(); i++)
|
||||
{
|
||||
if (!m_s[i].hasGroundElevation()) { return true; }
|
||||
}
|
||||
return false;
|
||||
return std::any_of(m_s.begin(), m_s.end(),
|
||||
[](const auto &situation) { return !situation.hasGroundElevation(); });
|
||||
}
|
||||
|
||||
bool CInterpolatorSpline::isAnySituationNearGroundRelevant() const
|
||||
{
|
||||
for (unsigned int i = 0; i < m_s.size(); i++)
|
||||
{
|
||||
if (!m_s[i].canLikelySkipNearGroundInterpolation()) { return true; }
|
||||
}
|
||||
return false;
|
||||
return std::any_of(m_s.begin(), m_s.end(),
|
||||
[](const auto &situation) { return !situation.canLikelySkipNearGroundInterpolation(); });
|
||||
}
|
||||
|
||||
CInterpolatorSpline::CInterpolant::CInterpolant(const CInterpolatorSpline::PosArray &pa,
|
||||
|
||||
@@ -226,9 +226,8 @@ namespace swift::misc
|
||||
"i", "o", "n", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "y", "y" });
|
||||
|
||||
QString output = "";
|
||||
for (int i = 0; i < candidate.length(); i++)
|
||||
for (const QChar c : candidate)
|
||||
{
|
||||
const QChar c = candidate[i];
|
||||
const qsizetype dIndex = diacriticLetters.indexOf(c);
|
||||
if (dIndex < 0) { output.append(c); }
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user