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

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

View File

@@ -719,7 +719,7 @@ namespace BlackMisc
QMutexLocker lock(&m_mutex);
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)

View File

@@ -498,8 +498,8 @@ namespace BlackMisc
// - type
// - value
if (object.size() != 1) { return object; } // no cache format
const QString key = object.keys().front();
const QJsonObject cacheObject = object.value(key).toObject();
const QString key = object.constBegin().key();
const QJsonObject cacheObject = object.constBegin()->toObject();
if (cacheObject.contains("type") && cacheObject.contains("value"))
{
const QString type = cacheObject.value("type").toString(); // just to verify in debugger
@@ -512,8 +512,8 @@ namespace BlackMisc
QJsonObject unwrapCache(const QJsonObject &object)
{
if (object.size() != 1) { return object; } // no cache format
const QString key = object.keys().front();
const QJsonObject cacheObject = object.value(key).toObject();
const QString key = object.constBegin().key();
const QJsonObject cacheObject = object.constBegin()->toObject();
if (cacheObject.contains("type") && cacheObject.contains("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 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);
if (it == m_patternHandlers.end())
auto it = std::find_if(m_patternHandlers.cbegin(), m_patternHandlers.cend(), finder);
if (it == m_patternHandlers.cend())
{
auto *handler = new CLogPatternHandler(this, pattern);
topologicallySortedInsert(m_patternHandlers, PatternPair(pattern, handler), comparator);

View File

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

View File

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