summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-11-17 20:02:14 +0100
committerJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-11-19 19:46:54 +0100
commit4e1bebf0f5e06ecdd99c41771e7b4ee19c0cdcf3 (patch)
treed0e98cee9eef416282049092ea93b0b2b6eb417d /src/util
parent133ea1e3d6547964f014144eee15590ea449c7af (diff)
Pass non-trivial/large function args by reference
Fixes a bunch of `-Wclazy-function-args-by-ref` warnings. See https://github.com/KDE/clazy/blob/master/docs/checks/README-function-args-by-ref.md for details. Most of these changes are automated, using the clazy fixit by setting the `CLAZY_EXPORT_FIXES` before compilation and then running: $ mkdir /tmp/patch $ find ../src -iname "*.yaml" -exec mv {} /tmp/patch \; $ clang-apply-replacements /tmp/patch
Diffstat (limited to 'src/util')
-rw-r--r--src/util/color/colorpalette.h8
-rw-r--r--src/util/db/dbconnection.cpp6
-rw-r--r--src/util/db/fwdsqlquery.cpp6
-rw-r--r--src/util/db/fwdsqlquery.h2
-rw-r--r--src/util/db/sqlqueryfinisher.h6
-rw-r--r--src/util/db/sqlstorage.h4
-rw-r--r--src/util/debug.h4
-rw-r--r--src/util/dnd.cpp6
-rw-r--r--src/util/dnd.h4
-rw-r--r--src/util/translations.h9
-rw-r--r--src/util/valuetransformer.cpp4
-rw-r--r--src/util/valuetransformer.h4
12 files changed, 33 insertions, 30 deletions
diff --git a/src/util/color/colorpalette.h b/src/util/color/colorpalette.h
index b3c4872013..48a8d0c3c8 100644
--- a/src/util/color/colorpalette.h
+++ b/src/util/color/colorpalette.h
@@ -10,9 +10,9 @@
class ColorPalette final {
public:
ColorPalette(
- QString name,
- QList<mixxx::RgbColor> colorList,
- QList<int> colorIndicesByHotcue = {})
+ const QString& name,
+ const QList<mixxx::RgbColor>& colorList,
+ const QList<int>& colorIndicesByHotcue = {})
: m_name(name),
m_colorList(colorList),
m_colorIndicesByHotcue(colorIndicesByHotcue) {
@@ -49,7 +49,7 @@ class ColorPalette final {
return m_name;
}
- void setName(const QString name) {
+ void setName(const QString& name) {
m_name = name;
}
diff --git a/src/util/db/dbconnection.cpp b/src/util/db/dbconnection.cpp
index 850c47c55a..e9b65d3188 100644
--- a/src/util/db/dbconnection.cpp
+++ b/src/util/db/dbconnection.cpp
@@ -24,7 +24,7 @@ const mixxx::Logger kLogger("DbConnection");
QSqlDatabase createDatabase(
const DbConnection::Params& params,
- const QString connectionName) {
+ const QString& connectionName) {
kLogger.info()
<< "Available drivers for database connections:"
<< QSqlDatabase::drivers();
@@ -41,7 +41,7 @@ QSqlDatabase createDatabase(
QSqlDatabase cloneDatabase(
const QSqlDatabase& database,
- const QString connectionName) {
+ const QString& connectionName) {
DEBUG_ASSERT(!database.isOpen());
return QSqlDatabase::cloneDatabase(database, connectionName);
}
@@ -233,7 +233,7 @@ void sqliteLike(sqlite3_context *context,
#endif // __SQLITE3__
-bool initDatabase(QSqlDatabase database, StringCollator* pCollator) {
+bool initDatabase(const QSqlDatabase& database, StringCollator* pCollator) {
DEBUG_ASSERT(database.isOpen());
#ifdef __SQLITE3__
QVariant v = database.driver()->handle();
diff --git a/src/util/db/fwdsqlquery.cpp b/src/util/db/fwdsqlquery.cpp
index d11b5327e9..d3b0467475 100644
--- a/src/util/db/fwdsqlquery.cpp
+++ b/src/util/db/fwdsqlquery.cpp
@@ -33,10 +33,10 @@ bool prepareQuery(QSqlQuery& query, const QString& statement) {
} // anonymous namespace
FwdSqlQuery::FwdSqlQuery(
- QSqlDatabase database,
+ const QSqlDatabase& database,
const QString& statement)
- : QSqlQuery(database),
- m_prepared(prepareQuery(*this, statement)) {
+ : QSqlQuery(database),
+ m_prepared(prepareQuery(*this, statement)) {
if (!m_prepared) {
DEBUG_ASSERT(!database.isOpen() || hasError());
kLogger.critical()
diff --git a/src/util/db/fwdsqlquery.h b/src/util/db/fwdsqlquery.h
index 734c2c1392..2ab2413587 100644
--- a/src/util/db/fwdsqlquery.h
+++ b/src/util/db/fwdsqlquery.h
@@ -36,7 +36,7 @@ class FwdSqlQuery: protected QSqlQuery {
public:
FwdSqlQuery(
- QSqlDatabase database,
+ const QSqlDatabase& database,
const QString& statement);
bool isPrepared() const {
diff --git a/src/util/db/sqlqueryfinisher.h b/src/util/db/sqlqueryfinisher.h
index 2eb16525dc..299bb7733b 100644
--- a/src/util/db/sqlqueryfinisher.h
+++ b/src/util/db/sqlqueryfinisher.h
@@ -10,9 +10,9 @@
// resources of prepared statements until the next execution.
class SqlQueryFinisher final {
public:
- explicit SqlQueryFinisher(QSqlQuery query)
- : m_query(query) { // implicitly shared (not copied)
- }
+ explicit SqlQueryFinisher(const QSqlQuery& query)
+ : m_query(query) { // implicitly shared (not copied)
+ }
SqlQueryFinisher(SqlQueryFinisher&& other)
: m_query(std::move(other.m_query)) { // implicitly shared (not moved)
other.release();
diff --git a/src/util/db/sqlstorage.h b/src/util/db/sqlstorage.h
index fa42bf4ab2..7b5fb461a5 100644
--- a/src/util/db/sqlstorage.h
+++ b/src/util/db/sqlstorage.h
@@ -18,7 +18,7 @@ class SqlStorage {
// strayed rows should be deleted.
// This function will only be called while no database
// is attached to avoid invalidation of internal caches!
- virtual void repairDatabase(QSqlDatabase database) = 0;
+ virtual void repairDatabase(const QSqlDatabase& database) = 0;
// Attach an open database connection to the storage class.
// Implementations might need to do the following:
@@ -29,7 +29,7 @@ class SqlStorage {
// until it is detached (see below). Implementations must
// store an implicitly shared copy of the QSqlDatabase for
// accessing it.
- virtual void connectDatabase(QSqlDatabase database) = 0;
+ virtual void connectDatabase(const QSqlDatabase& database) = 0;
// Detach the currently attached database, e.g. before
// closing it.
diff --git a/src/util/debug.h b/src/util/debug.h
index e1a59e86bd..f405e70b8a 100644
--- a/src/util/debug.h
+++ b/src/util/debug.h
@@ -23,7 +23,7 @@ QString toDebugString(const T& object) {
// the Qt event loop to continue processing. This means that you must not call
// this function from a code section which is not re-entrant (e.g. paintEvent on
// a QWidget).
-inline void reportFatalErrorAndQuit(QString message) {
+inline void reportFatalErrorAndQuit(const QString& message) {
QByteArray message_bytes = message.toLocal8Bit();
qFatal("%s", message_bytes.constData());
ErrorDialogHandler* dialogHandler = ErrorDialogHandler::instance();
@@ -37,7 +37,7 @@ inline void reportFatalErrorAndQuit(QString message) {
// user which allows the Qt event loop to continue processing. This means that
// you must not call this function from a code section which is not re-entrant
// (e.g. paintEvent on a QWidget).
-inline void reportCriticalErrorAndQuit(QString message) {
+inline void reportCriticalErrorAndQuit(const QString& message) {
qCritical() << message;
ErrorDialogHandler* dialogHandler = ErrorDialogHandler::instance();
if (dialogHandler) {
diff --git a/src/util/dnd.cpp b/src/util/dnd.cpp
index 947e435b4d..5dd3c3d11f 100644
--- a/src/util/dnd.cpp
+++ b/src/util/dnd.cpp
@@ -15,7 +15,7 @@ namespace {
QDrag* dragUrls(
const QList<QUrl>& trackUrls,
QWidget* pDragSource,
- QString sourceIdentifier) {
+ const QString& sourceIdentifier) {
if (trackUrls.isEmpty()) {
return NULL;
}
@@ -188,7 +188,7 @@ bool DragAndDropHelper::dragEnterAccept(
QDrag* DragAndDropHelper::dragTrack(
TrackPointer pTrack,
QWidget* pDragSource,
- QString sourceIdentifier) {
+ const QString& sourceIdentifier) {
QList<QUrl> trackUrls;
trackUrls.append(pTrack->getFileInfo().toUrl());
return dragUrls(trackUrls, pDragSource, sourceIdentifier);
@@ -198,7 +198,7 @@ QDrag* DragAndDropHelper::dragTrack(
QDrag* DragAndDropHelper::dragTrackLocations(
const QList<QString>& locations,
QWidget* pDragSource,
- QString sourceIdentifier) {
+ const QString& sourceIdentifier) {
QList<QUrl> trackUrls;
foreach (QString location, locations) {
trackUrls.append(TrackFile(location).toUrl());
diff --git a/src/util/dnd.h b/src/util/dnd.h
index 77d2b5a077..efd4d40e37 100644
--- a/src/util/dnd.h
+++ b/src/util/dnd.h
@@ -34,12 +34,12 @@ class DragAndDropHelper final {
static QDrag* dragTrack(
TrackPointer pTrack,
QWidget* pDragSource,
- QString sourceIdentifier);
+ const QString& sourceIdentifier);
static QDrag* dragTrackLocations(
const QList<QString>& locations,
QWidget* pDragSource,
- QString sourceIdentifier);
+ const QString& sourceIdentifier);
static void handleTrackDragEnterEvent(
QDragEnterEvent* event,
diff --git a/src/util/translations.h b/src/util/translations.h
index 7597e0e675..117cb2a402 100644
--- a/src/util/translations.h
+++ b/src/util/translations.h
@@ -78,9 +78,12 @@ class Translations {
}
private:
- static bool loadTranslations(const QLocale& systemLocale, QString userLocale,
- const QString& translation, const QString& prefix,
- const QString& translationPath, QTranslator* pTranslator) {
+ static bool loadTranslations(const QLocale& systemLocale,
+ const QString& userLocale,
+ const QString& translation,
+ const QString& prefix,
+ const QString& translationPath,
+ QTranslator* pTranslator) {
if (userLocale.size() == 0) {
QStringList uiLanguages = systemLocale.uiLanguages();
if (uiLanguages.size() > 0 && uiLanguages.first() == "en") {
diff --git a/src/util/valuetransformer.cpp b/src/util/valuetransformer.cpp
index f62da80ad2..f412d0da86 100644
--- a/src/util/valuetransformer.cpp
+++ b/src/util/valuetransformer.cpp
@@ -25,8 +25,8 @@ double ValueTransformer::transformInverse(double argument) const {
}
// static
-ValueTransformer* ValueTransformer::parseFromXml(QDomElement transformElement,
- const SkinContext& context) {
+ValueTransformer* ValueTransformer::parseFromXml(const QDomElement& transformElement,
+ const SkinContext& context) {
if (transformElement.isNull() || !transformElement.hasChildNodes()) {
return NULL;
}
diff --git a/src/util/valuetransformer.h b/src/util/valuetransformer.h
index 7d84369202..12018c666b 100644
--- a/src/util/valuetransformer.h
+++ b/src/util/valuetransformer.h
@@ -84,8 +84,8 @@ class ValueTransformer {
double transform(double argument) const;
double transformInverse(double argument) const;
- static ValueTransformer* parseFromXml(QDomElement transformElement,
- const SkinContext& context);
+ static ValueTransformer* parseFromXml(const QDomElement& transformElement,
+ const SkinContext& context);
private:
ValueTransformer();