summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-07-15 11:28:19 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-07-17 20:19:49 +0200
commitf75002d17f6b398e0d6b24f9dce2548dcef20c28 (patch)
tree109ce218a43c64f490e4b4301dad8b00d712fd56
parentff33b62872e36c3168b8941becb4d8c709151d5c (diff)
Small code optimizations
Change-Id: Ieaa5f3bc5bcba73552deb60b807f27acc11c4602 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
-rw-r--r--src/bluetooth/qlowenergycontrollernew.cpp4
-rw-r--r--src/bluetooth/qlowenergycontrollernew_bluez.cpp16
2 files changed, 10 insertions, 10 deletions
diff --git a/src/bluetooth/qlowenergycontrollernew.cpp b/src/bluetooth/qlowenergycontrollernew.cpp
index dc3997b2..3b499d3b 100644
--- a/src/bluetooth/qlowenergycontrollernew.cpp
+++ b/src/bluetooth/qlowenergycontrollernew.cpp
@@ -133,8 +133,7 @@ QLowEnergyCharacteristic QLowEnergyControllerNewPrivate::characteristicForHandle
if (service.isNull())
return QLowEnergyCharacteristic();
- QList<QLowEnergyHandle> charHandles = service->characteristicList.keys();
- if (charHandles.isEmpty())
+ if (service->characteristicList.isEmpty())
return QLowEnergyCharacteristic();
// check whether it is the handle of a characteristic header
@@ -142,6 +141,7 @@ QLowEnergyCharacteristic QLowEnergyControllerNewPrivate::characteristicForHandle
return QLowEnergyCharacteristic(service, handle);
// check whether it is the handle of the characteristic value or its descriptors
+ QList<QLowEnergyHandle> charHandles = service->characteristicList.keys();
std::sort(charHandles.begin(), charHandles.end());
for (int i = charHandles.size() - 1; i >= 0; i--) {
if (charHandles.at(i) > handle)
diff --git a/src/bluetooth/qlowenergycontrollernew_bluez.cpp b/src/bluetooth/qlowenergycontrollernew_bluez.cpp
index 7b0b5e4c..ad32ab0e 100644
--- a/src/bluetooth/qlowenergycontrollernew_bluez.cpp
+++ b/src/bluetooth/qlowenergycontrollernew_bluez.cpp
@@ -491,8 +491,8 @@ void QLowEnergyControllerNewPrivate::processReply(
Q_ASSERT(request.command == ATT_OP_READ_REQUEST);
uint ref = request.reference.toUInt();
- QLowEnergyHandle charHandle = (ref & 0xffff);
- QLowEnergyHandle descriptorHandle = ((ref >> 16) & 0xffff);
+ const QLowEnergyHandle charHandle = (ref & 0xffff);
+ const QLowEnergyHandle descriptorHandle = ((ref >> 16) & 0xffff);
// we ignore error response
if (!isErrorResponse) {
@@ -630,8 +630,8 @@ void QLowEnergyControllerNewPrivate::processReply(
Q_ASSERT(request.command == ATT_OP_WRITE_REQUEST);
uint ref = request.reference.toUInt();
- QLowEnergyHandle charHandle = (ref & 0xffff);
- QLowEnergyHandle descriptorHandle = ((ref >> 16) & 0xffff);
+ const QLowEnergyHandle charHandle = (ref & 0xffff);
+ const QLowEnergyHandle descriptorHandle = ((ref >> 16) & 0xffff);
QSharedPointer<QLowEnergyServicePrivate> service = serviceForHandle(charHandle);
if (service.isNull() || !service->characteristicList.contains(charHandle))
@@ -763,7 +763,7 @@ void QLowEnergyControllerNewPrivate::readServiceValues(
QList<QPair<QLowEnergyHandle, quint32> > targetHandles;
const QList<QLowEnergyHandle> keys = service->characteristicList.keys();
for (int i = 0; i < keys.count(); i++) {
- QLowEnergyHandle charHandle = keys[i];
+ const QLowEnergyHandle charHandle = keys[i];
const QLowEnergyServicePrivate::CharData &charDetails =
service->characteristicList[charHandle];
@@ -846,7 +846,7 @@ void QLowEnergyControllerNewPrivate::processUnsolicitedReply(const QByteArray &p
{
const char *data = payload.constData();
bool isNotification = (data[0] == ATT_OP_HANDLE_VAL_NOTIFICATION);
- QLowEnergyHandle changedHandle = bt_get_le16(&data[1]);
+ const QLowEnergyHandle changedHandle = bt_get_le16(&data[1]);
if (QT_BT_BLUEZ().isDebugEnabled()) {
if (isNotification)
@@ -855,7 +855,7 @@ void QLowEnergyControllerNewPrivate::processUnsolicitedReply(const QByteArray &p
qCDebug(QT_BT_BLUEZ) << "Change indication for handle" << hex << changedHandle;
}
- QLowEnergyCharacteristic ch = characteristicForHandle(changedHandle);
+ const QLowEnergyCharacteristic ch = characteristicForHandle(changedHandle);
if (ch.isValid() && ch.handle() == changedHandle) {
const QByteArray newValue = payload.mid(3).toHex();
updateValueOfCharacteristic(ch.attributeHandle(), newValue);
@@ -899,7 +899,7 @@ void QLowEnergyControllerNewPrivate::discoverNextDescriptor(
quint8 packet[FIND_INFO_REQUEST_SIZE];
packet[0] = ATT_OP_FIND_INFORMATION_REQUEST;
- QLowEnergyHandle charStartHandle = startingHandle;
+ const QLowEnergyHandle charStartHandle = startingHandle;
QLowEnergyHandle charEndHandle = 0;
if (pendingCharHandles.count() == 1) //single characteristic
charEndHandle = serviceData->endHandle;