summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins@kdab.com>2015-06-08 14:23:26 +0100
committerSérgio Martins <sergio.martins@kdab.com>2015-06-08 20:34:19 +0000
commit6452e1d21df010541900aa2fd4baa9e89c5fd382 (patch)
treed31993618b553cc0dacecba960aef41d4449ab4f
parent55d4273a155e795cd01a298bb9ba3c3d33154380 (diff)
downloadqtsensors-6452e1d21df010541900aa2fd4baa9e89c5fd382.tar.gz
qtsensors-6452e1d21df010541900aa2fd4baa9e89c5fd382.tar.bz2
qtsensors-6452e1d21df010541900aa2fd4baa9e89c5fd382.zip
Add two QList::reserve() calls.
Change-Id: Ie95283344006821ae2e84a3c6b01532cd4cf340f Reviewed-by: Vyacheslav Koscheev <vok1980@gmail.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
-rw-r--r--src/imports/sensors/qmlsensorglobal.cpp8
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;
}