mirror of https://github.com/qt/qtbase.git
QSqlQueryModel: memoize roleNames()
The return value of this function is constant and some users (QML?) may call this function often, so memoize the result of the function instead of re-creating the QHash on every call. Amends40206a9f6d
. Not picking to Qt 5, because I'm unsure about the state of magic statics there, and I don't want to take out the Q_GLOBAL_STATIC sledgehammer. Pick-to: 6.8 6.5 Change-Id: I8311e93ea16982c82e8312e1e104d95ed062fe6b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit0d0a151e0d
) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4ee61659c3
commit
dd1349240f
|
@ -193,9 +193,10 @@ bool QSqlQueryModel::canFetchMore(const QModelIndex &parent) const
|
|||
*/
|
||||
QHash<int, QByteArray> QSqlQueryModel::roleNames() const
|
||||
{
|
||||
return QHash<int, QByteArray> {
|
||||
static const QHash<int, QByteArray> names = {
|
||||
{ Qt::DisplayRole, QByteArrayLiteral("display") }
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
|
|
Loading…
Reference in New Issue