From 6452e1d21df010541900aa2fd4baa9e89c5fd382 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Mon, 8 Jun 2015 14:23:26 +0100 Subject: Add two QList::reserve() calls. Change-Id: Ie95283344006821ae2e84a3c6b01532cd4cf340f Reviewed-by: Vyacheslav Koscheev Reviewed-by: Marc Mutz --- src/imports/sensors/qmlsensorglobal.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/imports/sensors/qmlsensorglobal.cpp b/src/imports/sensors/qmlsensorglobal.cpp index 510ab238..7b993fe0 100644 --- a/src/imports/sensors/qmlsensorglobal.cpp +++ b/src/imports/sensors/qmlsensorglobal.cpp @@ -78,7 +78,9 @@ QmlSensorGlobal::~QmlSensorGlobal() QStringList QmlSensorGlobal::sensorTypes() const { QStringList ret; - foreach (const QByteArray &type, QSensor::sensorTypes()) + const QList sensorTypes = QSensor::sensorTypes(); + ret.reserve(sensorTypes.count()); + foreach (const QByteArray &type, sensorTypes) ret << QString::fromLocal8Bit(type); return ret; } @@ -92,7 +94,9 @@ QStringList QmlSensorGlobal::sensorTypes() const QStringList QmlSensorGlobal::sensorsForType(const QString &type) const { QStringList ret; - foreach (const QByteArray &identifier, QSensor::sensorsForType(type.toLocal8Bit())) + const QList sensors = QSensor::sensorsForType(type.toLocal8Bit()); + ret.reserve(sensors.count()); + foreach (const QByteArray &identifier, sensors) ret << QString::fromLocal8Bit(identifier); return ret; } -- cgit v1.2.3