mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #937 Resolved clazy warnings: unnecessary memory allocation.
This commit is contained in:
@@ -245,7 +245,7 @@ namespace BlackSample
|
||||
Q_ASSERT(splitList.size() == numberOfCallsigns);
|
||||
for (int t = 0; t < numberOfTimes; t++)
|
||||
{
|
||||
for (const CAircraftSituationList &slcs : splitList.values())
|
||||
for (const CAircraftSituationList &slcs : splitList)
|
||||
{
|
||||
CAircraftSituationList r = slcs.findBefore(baseTimeEpoch + 1 + (DeltaTime * t));
|
||||
Q_UNUSED(r);
|
||||
@@ -322,7 +322,7 @@ namespace BlackSample
|
||||
out << "Split by " << csSituations.size() << " callsigns, " << timer.elapsed() << "ms" << endl;
|
||||
|
||||
timer.start();
|
||||
for (const CAircraftSituationList &csl : csSituations.values())
|
||||
for (const CAircraftSituationList &csl : csSituations)
|
||||
{
|
||||
CAircraftSituationList csSituationsBefore = csl.findBefore(halfTime);
|
||||
CAircraftSituationList csSituationsAfter = csl.findAfter(halfTime - 1);
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace BlackSample
|
||||
void ServiceTool::dataTransferTestClient(const QString &address)
|
||||
{
|
||||
// send data as P2P to server (this can be session bus, too, but usually is P2P)
|
||||
const bool sb = (address.toLower().startsWith("session"));
|
||||
const bool sb = address.startsWith("session", Qt::CaseInsensitive);
|
||||
QDBusConnection connection = sb ?
|
||||
QDBusConnection::sessionBus() :
|
||||
QDBusConnection::connectToPeer(address, "p2pConnection");
|
||||
@@ -91,6 +91,8 @@ namespace BlackSample
|
||||
QTextStream qtin(stdin);
|
||||
QTextStream qtout(stdout);
|
||||
|
||||
const QList<double> list { 1.0, 2.0, 3.0 };
|
||||
|
||||
while (true)
|
||||
{
|
||||
QDBusMessage m = QDBusMessage::createSignal(
|
||||
@@ -115,8 +117,6 @@ namespace BlackSample
|
||||
qtout << "Send string via interface " << msg << endl;
|
||||
|
||||
// a list
|
||||
QList<double> list;
|
||||
list << 1.0 << 2.0 << 3.0;
|
||||
testServiceInterface.receiveList(list);
|
||||
qtout << "Send list via interface " << list.size() << endl;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace BlackSample
|
||||
"C:/Flight Simulator 9/Aircraft"
|
||||
}, streamOut, streamIn);
|
||||
|
||||
const CSimulatorInfo sim = fsDir.toLower().contains("simobjects") ? CSimulatorInfo::FSX : CSimulatorInfo::FS9;
|
||||
const CSimulatorInfo sim = fsDir.contains("simobjects", Qt::CaseInsensitive) ? CSimulatorInfo::FSX : CSimulatorInfo::FS9;
|
||||
CMultiSimulatorSettings multiSettings;
|
||||
const CSimulatorSettings originalSettings = multiSettings.getSettings(sim);
|
||||
CSimulatorSettings newSettings(originalSettings);
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace BlackSample
|
||||
QStringLiteral("C:/Flight Simulator 9/Aircraft")
|
||||
}, streamOut, streamIn);
|
||||
|
||||
const CSimulatorInfo sim = fsDir.toLower().contains("simobjects") ? CSimulatorInfo::FSX : CSimulatorInfo::FS9;
|
||||
const CSimulatorInfo sim = fsDir.contains("simobjects", Qt::CaseInsensitive) ? CSimulatorInfo::FSX : CSimulatorInfo::FS9;
|
||||
CMultiSimulatorSettings multiSettings;
|
||||
const CSimulatorSettings originalSettings = multiSettings.getSettings(sim);
|
||||
CSimulatorSettings newSettings(originalSettings);
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace BlackCore
|
||||
qint64 timeoutAircraftEpochMs = currentTimeMsEpoch - aircraftTimeoutMs;
|
||||
qint64 timeoutAtcEpochMs = currentTimeMsEpoch - atcTimeoutMs;
|
||||
|
||||
for (const CCallsign &callsign : m_aircraftCallsignTimestamps.keys())
|
||||
for (const CCallsign &callsign : m_aircraftCallsignTimestamps.keys()) // clazy:exclude=container-anti-pattern,range-loop
|
||||
{
|
||||
if (m_aircraftCallsignTimestamps.value(callsign) > timeoutAircraftEpochMs) { continue; }
|
||||
CLogMessage(this).debug() << "Aircraft " << callsign.toQString() << "timed out!";
|
||||
@@ -173,7 +173,7 @@ namespace BlackCore
|
||||
emit timeoutAircraft(callsign);
|
||||
}
|
||||
|
||||
for (const CCallsign &callsign : m_atcCallsignTimestamps.keys())
|
||||
for (const CCallsign &callsign : m_atcCallsignTimestamps.keys()) // clazy:exclude=container-anti-pattern,range-loop
|
||||
{
|
||||
if (m_atcCallsignTimestamps.value(callsign) > timeoutAtcEpochMs) { continue; }
|
||||
CLogMessage(this).debug() << "ATC " << callsign.toQString() << "timed out!";
|
||||
|
||||
@@ -790,9 +790,9 @@ namespace BlackCore
|
||||
{
|
||||
// Logic to set logoff time
|
||||
bool ok;
|
||||
const int h = zuluTime.left(2).toInt(&ok);
|
||||
const int h = zuluTime.leftRef(2).toInt(&ok);
|
||||
if (!ok) { return; }
|
||||
const int m = zuluTime.right(2).toInt(&ok);
|
||||
const int m = zuluTime.rightRef(2).toInt(&ok);
|
||||
if (!ok) { return; }
|
||||
QDateTime logoffDateTime = QDateTime::currentDateTimeUtc();
|
||||
logoffDateTime.setTime(QTime(h, m));
|
||||
|
||||
@@ -309,7 +309,7 @@ namespace BlackCore
|
||||
m_voiceChannelMapping.remove(BlackMisc::Aviation::CComSystem::Com1);
|
||||
|
||||
// If the voice channel is not used by anybody else
|
||||
if (!m_voiceChannelMapping.values().contains(oldVoiceChannel))
|
||||
if (!m_voiceChannelMapping.key(oldVoiceChannel))
|
||||
{
|
||||
oldVoiceChannel->leaveVoiceRoom();
|
||||
m_unusedVoiceChannels.push_back(oldVoiceChannel);
|
||||
@@ -324,7 +324,7 @@ namespace BlackCore
|
||||
{
|
||||
auto newVoiceChannel = getVoiceChannelBy(newRoomCom1);
|
||||
newVoiceChannel->setOwnAircraftCallsign(ownCallsign);
|
||||
bool inUse = m_voiceChannelMapping.values().contains(newVoiceChannel);
|
||||
bool inUse = m_voiceChannelMapping.key(newVoiceChannel);
|
||||
m_voiceChannelMapping.insert(BlackMisc::Aviation::CComSystem::Com1, newVoiceChannel);
|
||||
|
||||
// If the voice channel is not used by anybody else
|
||||
@@ -349,7 +349,7 @@ namespace BlackCore
|
||||
m_voiceChannelMapping.remove(BlackMisc::Aviation::CComSystem::Com2);
|
||||
|
||||
// If the voice channel is not used by anybody else
|
||||
if (!m_voiceChannelMapping.values().contains(oldVoiceChannel))
|
||||
if (!m_voiceChannelMapping.key(oldVoiceChannel))
|
||||
{
|
||||
oldVoiceChannel->leaveVoiceRoom();
|
||||
m_unusedVoiceChannels.push_back(oldVoiceChannel);
|
||||
@@ -364,7 +364,7 @@ namespace BlackCore
|
||||
{
|
||||
auto newVoiceChannel = getVoiceChannelBy(newRoomCom2);
|
||||
newVoiceChannel->setOwnAircraftCallsign(ownCallsign);
|
||||
bool inUse = m_voiceChannelMapping.values().contains(newVoiceChannel);
|
||||
bool inUse = m_voiceChannelMapping.key(newVoiceChannel);
|
||||
m_voiceChannelMapping.insert(BlackMisc::Aviation::CComSystem::Com2, newVoiceChannel);
|
||||
|
||||
// If the voice channel is not used by anybody else
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace BlackCore
|
||||
|
||||
if (this->m_shutdown) { return; }
|
||||
QString urlString(nwReply->url().toString());
|
||||
if (urlString.toLower().contains("logoff"))
|
||||
if (urlString.contains("logoff", Qt::CaseInsensitive))
|
||||
{
|
||||
sApp->deleteAllCookies();
|
||||
emit logoffFinished();
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace BlackCore
|
||||
CSimulatorPluginInfoList CPluginManagerSimulator::getAvailableSimulatorPlugins() const
|
||||
{
|
||||
CSimulatorPluginInfoList list;
|
||||
for (const auto &i : m_plugins.values())
|
||||
for (const auto &i : m_plugins)
|
||||
{
|
||||
list.push_back(i.info);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace BlackCore
|
||||
Weather::CWeatherDataPluginInfoList CPluginManagerWeatherData::getAvailableWeatherDataPlugins() const
|
||||
{
|
||||
BlackMisc::Weather::CWeatherDataPluginInfoList list;
|
||||
for (const auto &i : m_plugins.values())
|
||||
for (const auto &i : m_plugins)
|
||||
{
|
||||
list.push_back(i.info);
|
||||
}
|
||||
|
||||
@@ -488,12 +488,13 @@ namespace BlackCore
|
||||
|
||||
CTextMessageList radioMessages = messages.getRadioMessages();
|
||||
radioMessages.markAsSent();
|
||||
QVector<int> freqsVec;
|
||||
for (const auto &message : radioMessages)
|
||||
{
|
||||
// I could send the same message to n frequencies in one step
|
||||
// if this is really required, I need to group by message
|
||||
// currently I send individual messages
|
||||
QVector<int> freqsVec;
|
||||
freqsVec.clear();
|
||||
freqsVec.push_back(message.getFrequency().valueRounded(CFrequencyUnit::kHz(), 0));
|
||||
Vat_SendRadioMessage(m_net.data(), freqsVec.data(), freqsVec.size(), toFSD(message.getMessage()));
|
||||
emit textMessageSent(message);
|
||||
|
||||
@@ -263,8 +263,8 @@ namespace BlackCore
|
||||
{
|
||||
// ; !CLIENTS section
|
||||
int i = currentLine.lastIndexOf(' ');
|
||||
const QString attributes = currentLine.mid(i).trimmed();
|
||||
clientSectionAttributes = attributes.split(':', QString::SkipEmptyParts);
|
||||
const QVector<QStringRef> attributes = currentLine.midRef(i).trimmed().split(':', QString::SkipEmptyParts);
|
||||
for (const QStringRef &attr : attributes) { clientSectionAttributes.push_back(attr.toString()); }
|
||||
section = SectionNone; // reset
|
||||
}
|
||||
continue;
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace BlackMisc
|
||||
QString CAircraftIcaoCode::getAircraftType() const
|
||||
{
|
||||
if (this->m_combinedType.length() < 1) { return ""; }
|
||||
QString c(this->m_combinedType.left(1));
|
||||
QString c(this->m_combinedType.at(0));
|
||||
if (c == "-") { return ""; }
|
||||
return c;
|
||||
}
|
||||
@@ -587,10 +587,10 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
// turn E to P engine
|
||||
if (combinedCode.endsWith("E")) { return QStringList({ combinedCode.left(2) + "P"}); }
|
||||
if (combinedCode.endsWith("E")) { return QStringList({ combinedCode.leftRef(2) + "P"}); }
|
||||
|
||||
// turn T to H plane (tilt wing to helicopter
|
||||
if (combinedCode.startsWith("T")) { return QStringList({ "H" + combinedCode.right(2)}); }
|
||||
if (combinedCode.startsWith("T")) { return QStringList({ "H" + combinedCode.rightRef(2)}); }
|
||||
|
||||
// based on engine count
|
||||
QStringList codes;
|
||||
@@ -600,7 +600,7 @@ namespace BlackMisc
|
||||
for (int c = 2; c < 5; c++)
|
||||
{
|
||||
if (c == engineCount) { continue; }
|
||||
const QString code(combinedCode.left(1) + QString::number(c) + combinedCode.right(1));
|
||||
const QString code(combinedCode.at(0) + QString::number(c) + combinedCode.at(2));
|
||||
codes.push_back(code);
|
||||
}
|
||||
}
|
||||
@@ -667,7 +667,7 @@ namespace BlackMisc
|
||||
}
|
||||
else
|
||||
{
|
||||
c.append(engine.left(1));
|
||||
c.append(engine.at(0));
|
||||
}
|
||||
Q_ASSERT_X(c.length() == 3, Q_FUNC_INFO, "Wrong combined length");
|
||||
return c;
|
||||
|
||||
@@ -408,7 +408,7 @@ namespace BlackMisc
|
||||
if (pinsOnly)
|
||||
{
|
||||
auto pins = fromJson(json.value("pins").toArray());
|
||||
for (const auto &key : m_timestamps.keys())
|
||||
for (const auto &key : m_timestamps.keys()) // clazy:exclude=container-anti-pattern,range-loop
|
||||
{
|
||||
if (! pins.contains(key)) { m_timestamps.remove(key); }
|
||||
}
|
||||
|
||||
@@ -127,12 +127,12 @@ namespace BlackMisc
|
||||
{
|
||||
if (part.startsWith("host="))
|
||||
{
|
||||
host = part.mid(part.lastIndexOf("=") + 1).trimmed();
|
||||
host = part.midRef(part.lastIndexOf("=") + 1).trimmed().toString();
|
||||
}
|
||||
else if (part.startsWith("port="))
|
||||
{
|
||||
bool ok;
|
||||
port = part.mid(part.lastIndexOf("=") + 1).trimmed().toInt(&ok);
|
||||
port = part.midRef(part.lastIndexOf("=") + 1).trimmed().toInt(&ok);
|
||||
if (! ok) { port = -1; }
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ namespace BlackMisc
|
||||
void CDBusServer::removeAllObjects()
|
||||
{
|
||||
if (m_objects.isEmpty()) { return; }
|
||||
for (const QString &path : m_objects.keys())
|
||||
for (const QString &path : makeKeysRange(as_const(m_objects)))
|
||||
{
|
||||
switch (m_serverMode)
|
||||
{
|
||||
|
||||
@@ -414,7 +414,7 @@ namespace BlackMisc
|
||||
QJsonObject getIncrementalObject(const QJsonObject &previousObject, const QJsonObject ¤tObject)
|
||||
{
|
||||
QJsonObject incrementalObject = currentObject;
|
||||
for (const auto &key : previousObject.keys())
|
||||
for (const auto &key : previousObject.keys()) // clazy:exclude=range-loop
|
||||
{
|
||||
if (previousObject.value(key).isObject())
|
||||
{
|
||||
@@ -434,7 +434,7 @@ namespace BlackMisc
|
||||
QJsonObject applyIncrementalObject(const QJsonObject &previousObject, const QJsonObject &incrementalObject)
|
||||
{
|
||||
QJsonObject currentObject = previousObject;
|
||||
for (const auto &key : incrementalObject.keys())
|
||||
for (const auto &key : incrementalObject.keys()) // clazy:exclude=range-loop
|
||||
{
|
||||
// If it is not an object, just insert the value
|
||||
if (!incrementalObject.value(key).isObject())
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace BlackMisc
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
QString strategy;
|
||||
QString categories = QStringList(m_strings.toList()).join("|");
|
||||
QString categories = QStringList(m_strings.toList()).join("|"); // clazy:exclude=container-anti-pattern
|
||||
switch (m_strategy)
|
||||
{
|
||||
case Everything: strategy = "none"; break;
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace BlackMisc
|
||||
{
|
||||
int pos = match.capturedStart(0);
|
||||
QString icao = match.captured(0).trimmed().right(4);
|
||||
rn = rn.left(pos).trimmed();
|
||||
rn = rn.leftRef(pos).trimmed().toString();
|
||||
this->setHomeBase(CAirportIcaoCode(icao));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,10 +66,10 @@ namespace BlackMisc
|
||||
|
||||
if (ts.contains(":") && (ts.length() == 8 || ts.length() == 5))
|
||||
{
|
||||
const int hour = ts.mid(0, 2).toInt();
|
||||
const int minute = ts.mid(3, 2).toInt();
|
||||
const int hour = ts.midRef(0, 2).toInt();
|
||||
const int minute = ts.midRef(3, 2).toInt();
|
||||
int second = 0;
|
||||
if (ts.length() == 8) second = ts.mid(6, 2).toInt();
|
||||
if (ts.length() == 8) second = ts.midRef(6, 2).toInt();
|
||||
(*this) = CTime(hour, minute, second);
|
||||
|
||||
// fix sign if required
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace BlackMisc
|
||||
}
|
||||
else
|
||||
{
|
||||
f = this->m_indexString.left(p).toInt(&ok);
|
||||
f = this->m_indexString.leftRef(p).toInt(&ok);
|
||||
}
|
||||
Q_ASSERT_X(ok && f >= 0, Q_FUNC_INFO, "Invalid index");
|
||||
return f;
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace BlackMisc
|
||||
{
|
||||
if (this->isEmpty()) return QString("{wildcard: %1}").arg(this->m_wildcard ? "true" : "false");
|
||||
QString s;
|
||||
foreach (CPropertyIndex index, this->m_values.keys())
|
||||
for (const CPropertyIndex &index : makeKeysRange(this->m_values))
|
||||
{
|
||||
CVariant v = this->m_values.value(index);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace BlackMisc
|
||||
obj.insert("name", this->getName());
|
||||
obj.insert("modelstring", QJsonValue(this->m_modelString));
|
||||
obj.insert("description", QJsonValue(this->m_description));
|
||||
obj.insert("mode", QJsonValue(getModelModeAsString().left(1).toUpper()));
|
||||
obj.insert("mode", QJsonValue(getModelModeAsString().left(1).toUpper())); // clazy:exclude=qstring-left
|
||||
|
||||
// sims
|
||||
const CSimulatorInfo sim(getSimulator());
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace BlackMisc
|
||||
QString fltSection("[FLTSIM.0]");
|
||||
int fltsimCounter = 0;
|
||||
FileSection currentSection = Unknown;
|
||||
bool isRotorcraftPath = fileName.toLower().contains("rotorcraft");
|
||||
bool isRotorcraftPath = fileName.contains("rotorcraft", Qt::CaseInsensitive);
|
||||
|
||||
while (!in.atEnd())
|
||||
{
|
||||
@@ -391,7 +391,7 @@ namespace BlackMisc
|
||||
if (index < 0) { return ""; }
|
||||
if (line.length() < index + 1) { return ""; }
|
||||
|
||||
QString content(line.mid(index + 1).trimmed());
|
||||
QString content(line.midRef(index + 1).trimmed().toString());
|
||||
|
||||
// fix "" strings, some are malformed and just contain " at beginning, not at the end
|
||||
if (content.endsWith('"')) { content.remove(content.size() - 1 , 1); }
|
||||
|
||||
@@ -47,9 +47,9 @@ namespace BlackMisc
|
||||
|
||||
QString s(yyyyMMddhhmmsszzz);
|
||||
s.remove(':').remove(' ').remove('-').remove('.'); // plain vanilla string
|
||||
int year(s.left(4).toInt());
|
||||
int month(s.mid(4, 2).toInt());
|
||||
int day(s.mid(6, 2).toInt());
|
||||
int year(s.leftRef(4).toInt());
|
||||
int month(s.midRef(4, 2).toInt());
|
||||
int day(s.midRef(6, 2).toInt());
|
||||
QDate date;
|
||||
date.setDate(year, month, day);
|
||||
QDateTime dt;
|
||||
@@ -62,10 +62,10 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
QTime t;
|
||||
int hour(s.mid(8, 2).toInt());
|
||||
int minute(s.mid(10, 2).toInt());
|
||||
int second(s.length() < 14 ? 0 : s.mid(12, 2).toInt());
|
||||
int ms(s.length() < 17 ? 0 : s.right(3).toInt());
|
||||
int hour(s.midRef(8, 2).toInt());
|
||||
int minute(s.midRef(10, 2).toInt());
|
||||
int second(s.length() < 14 ? 0 : s.midRef(12, 2).toInt());
|
||||
int ms(s.length() < 17 ? 0 : s.rightRef(3).toInt());
|
||||
|
||||
t.setHMS(hour, minute, second, ms);
|
||||
dt.setTime(t);
|
||||
|
||||
@@ -458,7 +458,7 @@ namespace BlackMisc
|
||||
CVariantMap temp;
|
||||
if (keysOnly)
|
||||
{
|
||||
for (const auto &key : json.object().keys()) { temp.insert(key, {}); }
|
||||
for (const auto &key : json.object().keys()) { temp.insert(key, {}); } // clazy:exclude=range-loop
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
QString weatherPhenomenaAsString;
|
||||
for (const auto &wp : weatherPhenomenaHash.keys())
|
||||
for (const auto &wp : makeKeysRange(weatherPhenomenaHash))
|
||||
{
|
||||
if (m_weatherPhenomena & wp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user