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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user