diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-08-26 11:37:47 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-08-27 10:08:30 +0200 |
commit | 9f4c45b58b82b59740dc60e22cba6894efd6c164 (patch) | |
tree | 578325ff39d2042546830ac5323e2ecab7c7cb77 /src/bluetooth/qbluetoothuuid.cpp | |
parent | 8a02c2ffd83afc17a4ea825e4954705ce21da99c (diff) |
Improve quint128 to QBluetoothUuid conversion performance
The change improves the performance between 8-10%.
Change-Id: I342e669d3f18cd2179b65f1af172db52303ff44c
Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Diffstat (limited to 'src/bluetooth/qbluetoothuuid.cpp')
-rw-r--r-- | src/bluetooth/qbluetoothuuid.cpp | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp index 7229889d..15d238e1 100644 --- a/src/bluetooth/qbluetoothuuid.cpp +++ b/src/bluetooth/qbluetoothuuid.cpp @@ -468,17 +468,9 @@ QBluetoothUuid::QBluetoothUuid(quint32 uuid) */ QBluetoothUuid::QBluetoothUuid(quint128 uuid) { - // TODO: look at the memcpy(), should not be needed - quint32 tmp32; - memcpy(&tmp32, &uuid.data[0], 4); - data1 = qFromBigEndian<quint32>(tmp32); - - quint16 tmp16; - memcpy(&tmp16, &uuid.data[4], 2); - data2 = qFromBigEndian<quint16>(tmp16); - - memcpy(&tmp16, &uuid.data[6], 2); - data3 = qFromBigEndian<quint16>(tmp16); + data1 = qFromBigEndian<quint32>(*reinterpret_cast<quint32 *>(&uuid.data[0])); + data2 = qFromBigEndian<quint16>(*reinterpret_cast<quint16 *>(&uuid.data[4])); + data3 = qFromBigEndian<quint16>(*reinterpret_cast<quint16 *>(&uuid.data[6])); memcpy(data4, &uuid.data[8], 8); } |