mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
Use structured bindings (C++17 feature)
This commit is contained in:
@@ -566,11 +566,11 @@ namespace BlackMisc
|
||||
{
|
||||
const QMap<QString, int> modelStrings = this->countPerModelString();
|
||||
CAircraftModelList duplicates;
|
||||
for (const auto pair : makePairsRange(modelStrings))
|
||||
for (const auto [string, count] : makePairsRange(modelStrings))
|
||||
{
|
||||
if (pair.second > 1)
|
||||
if (count > 1)
|
||||
{
|
||||
duplicates.push_back(this->findByModelString(pair.first, Qt::CaseInsensitive));
|
||||
duplicates.push_back(this->findByModelString(string, Qt::CaseInsensitive));
|
||||
}
|
||||
}
|
||||
return duplicates;
|
||||
|
||||
@@ -53,15 +53,14 @@ namespace BlackMisc
|
||||
// used simple string JSON generation as it is faster
|
||||
QString json;
|
||||
|
||||
for (const auto pair : makePairsRange(m_modelStringVsCG))
|
||||
for (const auto [string, cg] : makePairsRange(m_modelStringVsCG))
|
||||
{
|
||||
json += QStringLiteral("{ \"type\": \"cg\", \"modelstring\": \"%1\", \"cgft\": %2 },\n").arg(pair.first, pair.second.valueRoundedAsString(CLengthUnit::ft(), 1));
|
||||
json += QStringLiteral("{ \"type\": \"cg\", \"modelstring\": \"%1\", \"cgft\": %2 },\n").arg(string, cg.valueRoundedAsString(CLengthUnit::ft(), 1));
|
||||
}
|
||||
|
||||
for (const auto pair : makePairsRange(m_modelStringVsSimulatorInfo))
|
||||
for (const auto [string, sim] : makePairsRange(m_modelStringVsSimulatorInfo))
|
||||
{
|
||||
const QString sim = pair.second.toQString(false);
|
||||
json += QStringLiteral("{ \"type\": \"simulatorupdate\", \"modelstring\": \"%1\", \"simulator\": \"%2\" },\n").arg(pair.first, sim);
|
||||
json += QStringLiteral("{ \"type\": \"simulatorupdate\", \"modelstring\": \"%1\", \"simulator\": \"%2\" },\n").arg(string, sim.toQString(false));
|
||||
}
|
||||
|
||||
if (json.isEmpty()) { return {}; }
|
||||
|
||||
@@ -61,9 +61,9 @@ namespace BlackMisc
|
||||
{
|
||||
const SetupsPerCallsign setups = this->getSetupsPerCallsign();
|
||||
CCallsignSet callsigns;
|
||||
for (const auto pair : makePairsRange(setups))
|
||||
for (const auto [callsign, setup] : makePairsRange(setups))
|
||||
{
|
||||
if (pair.second.logInterpolation()) { callsigns.insert(pair.first); }
|
||||
if (setup.logInterpolation()) { callsigns.insert(callsign); }
|
||||
}
|
||||
return callsigns;
|
||||
}
|
||||
@@ -145,19 +145,18 @@ namespace BlackMisc
|
||||
|
||||
void IInterpolationSetupProvider::clearInterpolationLogCallsigns()
|
||||
{
|
||||
const SetupsPerCallsign setupsCopy = this->getSetupsPerCallsign();
|
||||
SetupsPerCallsign setupsCopy = this->getSetupsPerCallsign();
|
||||
if (setupsCopy.isEmpty()) { return; }
|
||||
|
||||
// potential risk, changes inbetween in another thread are missed now
|
||||
// on the other side, we keep locks for a minimal time frame
|
||||
SetupsPerCallsign setupsToKeep;
|
||||
CInterpolationAndRenderingSetupGlobal global = this->getInterpolationSetupGlobal();
|
||||
for (const auto pair : makePairsRange(setupsCopy))
|
||||
for (auto [callsign, setup] : makePairsRange(setupsCopy))
|
||||
{
|
||||
CInterpolationAndRenderingSetupPerCallsign setup = pair.second;
|
||||
setup.setLogInterpolation(false);
|
||||
if (setup.isEqualToGlobal(global)) { continue; }
|
||||
setupsToKeep.insert(pair.first, setup);
|
||||
setupsToKeep.insert(callsign, setup);
|
||||
}
|
||||
{
|
||||
QWriteLocker l(&m_lockSetup);
|
||||
|
||||
Reference in New Issue
Block a user