From cf0ddf24c02faf3de20fb4821cb9aed7915501d3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 15 Aug 2014 15:25:03 +0200 Subject: QKeySequence: replace an inefficient QList with QVector QModifKeyName is larger than a pointer, so holding it in a QList is horribly inefficient. Fix by marking it movable and using QVector instead. The logic for filling the lists-turned-vectors is a bit fishy in that it is not thread-safe. Maybe it doesn't have to, it's not marked as \reentrant. Change-Id: I8421e6d8b980eff022badfe3c61b3537783b5cfa Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/kernel/qkeysequence.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/gui/kernel/qkeysequence.cpp') diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 2e6bbfd5e1..ffa9b87147 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1017,9 +1017,10 @@ struct QModifKeyName { int qt_key; QString name; }; +Q_DECLARE_TYPEINFO(QModifKeyName, Q_MOVABLE_TYPE); -Q_GLOBAL_STATIC(QList, globalModifs) -Q_GLOBAL_STATIC(QList, globalPortableModifs) +Q_GLOBAL_STATIC(QVector, globalModifs) +Q_GLOBAL_STATIC(QVector, globalPortableModifs) /*! Constructs a single key from the string \a str. @@ -1035,7 +1036,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence QString accel = str.toLower(); bool nativeText = (format == QKeySequence::NativeText); - QList *gmodifs; + QVector *gmodifs; if (nativeText) { gmodifs = globalModifs(); if (gmodifs->isEmpty()) { @@ -1071,7 +1072,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence if (!gmodifs) return ret; - QList modifs; + QVector modifs; if (nativeText) { modifs << QModifKeyName(Qt::CTRL, QCoreApplication::translate("QShortcut", "Ctrl").toLower().append(QLatin1Char('+'))) << QModifKeyName(Qt::SHIFT, QCoreApplication::translate("QShortcut", "Shift").toLower().append(QLatin1Char('+'))) -- cgit v1.2.3