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>bb10
parent
1e701cf062
commit
016b5bc949
|
|
@ -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"));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
Loading…
Reference in New Issue