diff options
author | Sergio Martins <sergio.martins@kdab.com> | 2015-06-08 14:23:26 +0100 |
---|---|---|
committer | Sérgio Martins <sergio.martins@kdab.com> | 2015-06-08 20:34:19 +0000 |
commit | 6452e1d21df010541900aa2fd4baa9e89c5fd382 (patch) | |
tree | d31993618b553cc0dacecba960aef41d4449ab4f /src/imports | |
parent | 55d4273a155e795cd01a298bb9ba3c3d33154380 (diff) | |
download | qtsensors-6452e1d21df010541900aa2fd4baa9e89c5fd382.tar.gz |
Add two QList::reserve() calls.
Change-Id: Ie95283344006821ae2e84a3c6b01532cd4cf340f
Reviewed-by: Vyacheslav Koscheev <vok1980@gmail.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/sensors/qmlsensorglobal.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/imports/sensors/qmlsensorglobal.cpp b/src/imports/sensors/qmlsensorglobal.cpp index 510ab23..7b993fe 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<QByteArray> 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<QByteArray> sensors = QSensor::sensorsForType(type.toLocal8Bit()); + ret.reserve(sensors.count()); + foreach (const QByteArray &identifier, sensors) ret << QString::fromLocal8Bit(identifier); return ret; } |