Fixed clazy warnings: unnecessary containers and containers being detached.

This commit is contained in:
Mat Sutcliffe
2018-12-17 17:43:31 +00:00
parent 462172a87f
commit c71d358648
9 changed files with 14 additions and 14 deletions

View File

@@ -59,7 +59,7 @@ namespace BlackGui
if (c.isEmpty()) { return; } if (c.isEmpty()) { return; }
if (c.startsWith('.')) if (c.startsWith('.'))
{ {
if (c.toLower().contains("help")) if (c.contains("help", Qt::CaseInsensitive))
{ {
this->setCommandTooltip(); this->setCommandTooltip();
return; return;

View File

@@ -320,10 +320,10 @@ namespace BlackGui
QList<CMenuAction> toQList() const; QList<CMenuAction> toQList() const;
//! First action //! First action
CMenuAction first() const { return toQList().first(); } CMenuAction first() const { return m_actions.first(); }
//! Last action //! Last action
CMenuAction last() const { return toQList().last(); } CMenuAction last() const { return m_actions.last(); }
//! All actions; //! All actions;
operator QList<QAction *>() const; operator QList<QAction *>() const;

View File

@@ -513,7 +513,7 @@ namespace BlackGui
if (!m_pendingMessageCalls.isEmpty()) if (!m_pendingMessageCalls.isEmpty())
{ {
std::function<void()> f = m_pendingMessageCalls.front(); std::function<void()> f = m_pendingMessageCalls.constFirst();
m_pendingMessageCalls.removeFirst(); m_pendingMessageCalls.removeFirst();
const QPointer<COverlayMessages> myself(this); const QPointer<COverlayMessages> myself(this);
QTimer::singleShot(500, this, [ = ] QTimer::singleShot(500, this, [ = ]

View File

@@ -218,7 +218,7 @@ namespace BlackMisc
CSpeed guessedVRotate = this->isVtol() ? CSpeed::null() : CSpeed(70, CSpeedUnit::km_h()); CSpeed guessedVRotate = this->isVtol() ? CSpeed::null() : CSpeed(70, CSpeedUnit::km_h());
const int engines = this->getEnginesCount(); const int engines = this->getEnginesCount();
const QChar engineType = this->getEngineType()[0].toUpper(); const QChar engineType = this->getEngineType().at(0).toUpper();
do do
{ {
if (engines == 1) if (engines == 1)

View File

@@ -719,7 +719,7 @@ namespace BlackMisc
QMutexLocker lock(&m_mutex); QMutexLocker lock(&m_mutex);
Q_ASSERT(! m_updateInProgress); Q_ASSERT(! m_updateInProgress);
m_sessionValues[key]; // insert default-constructed value, unless key already present m_sessionValues[key]; // clazy:exclude=detaching-member
} }
QJsonObject CDataCacheRevision::toJson(const QMap<QString, qint64> &timestamps) QJsonObject CDataCacheRevision::toJson(const QMap<QString, qint64> &timestamps)

View File

@@ -498,8 +498,8 @@ namespace BlackMisc
// - type // - type
// - value // - value
if (object.size() != 1) { return object; } // no cache format if (object.size() != 1) { return object; } // no cache format
const QString key = object.keys().front(); const QString key = object.constBegin().key();
const QJsonObject cacheObject = object.value(key).toObject(); const QJsonObject cacheObject = object.constBegin()->toObject();
if (cacheObject.contains("type") && cacheObject.contains("value")) if (cacheObject.contains("type") && cacheObject.contains("value"))
{ {
const QString type = cacheObject.value("type").toString(); // just to verify in debugger const QString type = cacheObject.value("type").toString(); // just to verify in debugger
@@ -512,8 +512,8 @@ namespace BlackMisc
QJsonObject unwrapCache(const QJsonObject &object) QJsonObject unwrapCache(const QJsonObject &object)
{ {
if (object.size() != 1) { return object; } // no cache format if (object.size() != 1) { return object; } // no cache format
const QString key = object.keys().front(); const QString key = object.constBegin().key();
const QJsonObject cacheObject = object.value(key).toObject(); const QJsonObject cacheObject = object.constBegin()->toObject();
if (cacheObject.contains("type") && cacheObject.contains("value")) if (cacheObject.contains("type") && cacheObject.contains("value"))
{ {
// return object in form type/value // return object in form type/value

View File

@@ -82,8 +82,8 @@ namespace BlackMisc
auto finder = [ & ](const PatternPair &pair) { return pair.first == pattern; }; auto finder = [ & ](const PatternPair &pair) { return pair.first == pattern; };
auto comparator = [](const PatternPair &a, const PatternPair &b) { return a.first.isProperSubsetOf(b.first); }; auto comparator = [](const PatternPair &a, const PatternPair &b) { return a.first.isProperSubsetOf(b.first); };
auto it = std::find_if(m_patternHandlers.begin(), m_patternHandlers.end(), finder); auto it = std::find_if(m_patternHandlers.cbegin(), m_patternHandlers.cend(), finder);
if (it == m_patternHandlers.end()) if (it == m_patternHandlers.cend())
{ {
auto *handler = new CLogPatternHandler(this, pattern); auto *handler = new CLogPatternHandler(this, pattern);
topologicallySortedInsert(m_patternHandlers, PatternPair(pattern, handler), comparator); topologicallySortedInsert(m_patternHandlers, PatternPair(pattern, handler), comparator);

View File

@@ -537,7 +537,7 @@ namespace BlackMisc
{ {
static const QString empty; static const QString empty;
if (this->getModelDirectoriesOrDefault().isEmpty()) { return empty; } if (this->getModelDirectoriesOrDefault().isEmpty()) { return empty; }
return this->getModelDirectoriesOrDefault().first(); return this->getModelDirectoriesOrDefault().constFirst();
} }
const QStringList &CSpecializedSimulatorSettings::getDefaultModelDirectories() const const QStringList &CSpecializedSimulatorSettings::getDefaultModelDirectories() const

View File

@@ -418,7 +418,7 @@ namespace BlackMisc
if (simulator.isNoSimulator() || simulator.isUnspecified()) if (simulator.isNoSimulator() || simulator.isUnspecified())
{ {
// unknown count // unknown count
m_counts[5] = m_counts[5] + 1; m_counts[5]++;
return; return;
} }
if (simulator.isFSX()) { m_counts[0]++; } if (simulator.isFSX()) { m_counts[0]++; }