summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-10-19 12:20:10 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-10-21 09:13:09 +0000
commit016b5bc949b6dfb2f76db2e8b40a40e7eaee6828 (patch)
tree042b786f9ff437c79a492e927e2396268aa1697c /src/plugins
parent1e701cf0622fa7a5f194519b6afc7ef659f75cd7 (diff)
Plugins: use reserve() to optimize memory allocations
Change-Id: Id78ce43137e352292a9933222fe2f92d4ff4d69b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp1
-rw-r--r--src/plugins/platforms/mirclient/qmirclientinput.cpp1
-rw-r--r--src/plugins/platforms/openwfd/qopenwfdintegration.cpp1
-rw-r--r--src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp1
-rw-r--r--src/plugins/platforms/xcb/qxcbmime.cpp1
5 files changed, 5 insertions, 0 deletions
diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
index a4d7e504b7..bd25992457 100644
--- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
+++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp
@@ -255,6 +255,7 @@ void TableGenerator::initPossibleLocations()
// never meant for external software to parse compose tables directly. Best we
// can do is to hardcode search paths. To add an extra system path use
// the QTCOMPOSE environment variable
+ m_possibleLocations.reserve(7);
if (qEnvironmentVariableIsSet("QTCOMPOSE"))
m_possibleLocations.append(QString::fromLocal8Bit(qgetenv("QTCOMPOSE")));
m_possibleLocations.append(QStringLiteral("/usr/share/X11/locale"));
diff --git a/src/plugins/platforms/mirclient/qmirclientinput.cpp b/src/plugins/platforms/mirclient/qmirclientinput.cpp
index 4817185d41..b3b21ae0e3 100644
--- a/src/plugins/platforms/mirclient/qmirclientinput.cpp
+++ b/src/plugins/platforms/mirclient/qmirclientinput.cpp
@@ -347,6 +347,7 @@ void QMirClientInput::dispatchTouchEvent(QMirClientWindow *window, const MirInpu
// TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left
// as Qt::TouchPointMoved
const unsigned int kPointerCount = mir_touch_event_point_count(tev);
+ touchPoints.reserve(int(kPointerCount));
for (unsigned int i = 0; i < kPointerCount; ++i) {
QWindowSystemInterface::TouchPoint touchPoint;
diff --git a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp
index 9ed61f7b2e..4850ca2e45 100644
--- a/src/plugins/platforms/openwfd/qopenwfdintegration.cpp
+++ b/src/plugins/platforms/openwfd/qopenwfdintegration.cpp
@@ -68,6 +68,7 @@ QOpenWFDIntegration::QOpenWFDIntegration()
int actualNumberOfDevices = wfdEnumerateDevices(devices,numberOfDevices,0);
Q_ASSERT(actualNumberOfDevices == numberOfDevices);
+ mDevices.reserve(actualNumberOfDevices);
for (int i = 0; i < actualNumberOfDevices; i++) {
mDevices.append(new QOpenWFDDevice(this,devices[i]));
}
diff --git a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp
index 90a09d3087..a6236f2376 100644
--- a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp
+++ b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp
@@ -67,6 +67,7 @@ QQnxButtonEventNotifier::QQnxButtonEventNotifier(QObject *parent)
// fetch the new button ids
int enumeratorIndex = QQnxButtonEventNotifier::staticMetaObject.indexOfEnumerator(QByteArrayLiteral("ButtonId"));
QMetaEnum enumerator = QQnxButtonEventNotifier::staticMetaObject.enumerator(enumeratorIndex);
+ m_buttonKeys.reserve(ButtonCount - bid_minus);
for (int buttonId = bid_minus; buttonId < ButtonCount; ++buttonId) {
m_buttonKeys.append(enumerator.valueToKey(buttonId));
m_state[buttonId] = ButtonUp;
diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp
index 3e9b0e1e4a..3643b3e975 100644
--- a/src/plugins/platforms/xcb/qxcbmime.cpp
+++ b/src/plugins/platforms/xcb/qxcbmime.cpp
@@ -210,6 +210,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
if (format == QLatin1String("text/uri-list")) {
const auto urls = str.splitRef(QLatin1Char('\n'));
QList<QVariant> list;
+ list.reserve(urls.size());
for (const QStringRef &s : urls) {
const QUrl url(s.trimmed().toString());
if (url.isValid())