summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-08-15 15:25:03 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-07-13 10:36:49 +0000
commitcf0ddf24c02faf3de20fb4821cb9aed7915501d3 (patch)
tree0f64bd6e1bd5a4061e3721823efc42487fdbba07
parent4d7f528dde58d05b403037ffdd660b3e55601d62 (diff)
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) <ogoffart@woboq.com>
-rw-r--r--src/gui/kernel/qkeysequence.cpp9
1 files changed, 5 insertions, 4 deletions
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<QModifKeyName>, globalModifs)
-Q_GLOBAL_STATIC(QList<QModifKeyName>, globalPortableModifs)
+Q_GLOBAL_STATIC(QVector<QModifKeyName>, globalModifs)
+Q_GLOBAL_STATIC(QVector<QModifKeyName>, 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<QModifKeyName> *gmodifs;
+ QVector<QModifKeyName> *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<QModifKeyName> modifs;
+ QVector<QModifKeyName> modifs;
if (nativeText) {
modifs << QModifKeyName(Qt::CTRL, QCoreApplication::translate("QShortcut", "Ctrl").toLower().append(QLatin1Char('+')))
<< QModifKeyName(Qt::SHIFT, QCoreApplication::translate("QShortcut", "Shift").toLower().append(QLatin1Char('+')))