From 2adfb9c65334f251a0dc2ec10d43d8a24cea9a6e Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 30 May 2024 15:51:28 +0200 Subject: QmlCompiler: Fix various style issues Don't copy QQmlJSScope::ConstPtr where it can be avoided, keep things const where we can, pass values as const ref and return them as value, std::move where possible and easily visible. Coverity-Id: 462267 Coverity-Id: 462268 Coverity-Id: 462269 Coverity-Id: 462271 Coverity-Id: 462272 Coverity-Id: 462273 Coverity-Id: 462275 Coverity-Id: 462276 Coverity-Id: 462277 Coverity-Id: 462278 Coverity-Id: 462279 Coverity-Id: 462281 Coverity-Id: 462283 Coverity-Id: 462284 Coverity-Id: 462285 Change-Id: I2c8f2267d5ab521145111f7b56eaad6cf0234a77 Reviewed-by: Fabian Kosmale --- src/qmlcompiler/qqmljscompilerstats.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/qmlcompiler/qqmljscompilerstats.cpp') diff --git a/src/qmlcompiler/qqmljscompilerstats.cpp b/src/qmlcompiler/qqmljscompilerstats.cpp index b65afd412f..9e564834e7 100644 --- a/src/qmlcompiler/qqmljscompilerstats.cpp +++ b/src/qmlcompiler/qqmljscompilerstats.cpp @@ -26,7 +26,7 @@ bool QQmlJS::AotStatsEntry::operator<(const AotStatsEntry &other) const return line < other.line; } -void AotStats::insert(AotStats other) +void AotStats::insert(const AotStats &other) { for (const auto &[moduleUri, moduleStats] : other.m_entries.asKeyValueRange()) { m_entries[moduleUri].insert(moduleStats); @@ -111,10 +111,10 @@ AotStats AotStats::fromJsonDocument(const QJsonDocument &document) } std::sort(stats.begin(), stats.end()); - files[filepath] = stats; + files[filepath] = std::move(stats); } - result.m_entries[moduleId] = files; + result.m_entries[moduleId] = std::move(files); } return result; @@ -160,7 +160,8 @@ QJsonDocument AotStats::toJsonDocument() const return QJsonDocument(modulesArray); } -void AotStats::addEntry(const QString &moduleId, const QString &filepath, AotStatsEntry entry) +void AotStats::addEntry( + const QString &moduleId, const QString &filepath, const AotStatsEntry &entry) { m_entries[moduleId][filepath].append(entry); } @@ -177,10 +178,9 @@ bool AotStats::saveToDisk(const QString &filepath) const return true; } -void QQmlJSAotCompilerStats::addEntry(QString filepath, QQmlJS::AotStatsEntry entry) +void QQmlJSAotCompilerStats::addEntry(const QString &filepath, const QQmlJS::AotStatsEntry &entry) { - auto *aotstats = QQmlJSAotCompilerStats::instance(); - aotstats->addEntry(s_moduleId, filepath, entry); + QQmlJSAotCompilerStats::instance()->addEntry(s_moduleId, filepath, entry); } } // namespace QQmlJS -- cgit v1.2.3