Optimize Song::InitFromQuery

Use `QSqlQuery::value(int)` or `QSqlRecord::value(int)` instead of `QSqlQuery::value(QString)`.
Make `SqlRow` use `QSqlRecord` directly instead iterating over all columns.
This commit is contained in:
Jonas Kvinge
2024-04-21 15:42:22 +02:00
parent 7b88be2635
commit df070ac0cf
16 changed files with 266 additions and 184 deletions

View File

@@ -1,6 +1,6 @@
/*
* Strawberry Music Player
* Copyright 2021, Jonas Kvinge <jonas@jkvinge.net>
* Copyright 2021-2024, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,12 +29,15 @@
#include <QString>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlRecord>
class SqlQuery : public QSqlQuery {
public:
explicit SqlQuery(const QSqlDatabase &db) : QSqlQuery(db) {}
int columns() const { return QSqlQuery::record().count(); }
void BindValue(const QString &placeholder, const QVariant &value);
void BindStringValue(const QString &placeholder, const QString &value);
void BindUrlValue(const QString &placeholder, const QUrl &value);