summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothuuid.h
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2021-02-26 14:17:37 +0100
committerAlex Blasche <alexander.blasche@qt.io>2021-03-09 16:13:00 +0100
commitb22b97bf5e11795f963b68472ac86cc50139aed0 (patch)
tree2191a6f6b6b18acac321e3b1d420e60831083f08 /src/bluetooth/qbluetoothuuid.h
parentd2e9a5113eab4a1eda45cb3d945faca8e01cbb7f (diff)
Optimize QBluetoothUuid ctors and make use of QUuid optimizations
Constexpr usage shifts the ctors to inline implementation. In addition, the meta type registration has to be separated from the ctor implementation. A global static variable takes care of this now. This optimization speeds the ctor performance by factor 15. Change-Id: I7443a84554611e6a0c857c1e295648fae1e858b5 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothuuid.h')
-rw-r--r--src/bluetooth/qbluetoothuuid.h23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/bluetooth/qbluetoothuuid.h b/src/bluetooth/qbluetoothuuid.h
index dd587694..af3e2116 100644
--- a/src/bluetooth/qbluetoothuuid.h
+++ b/src/bluetooth/qbluetoothuuid.h
@@ -366,13 +366,22 @@ public:
EnvironmentalSensingTriggerSetting = 0x290d
};
- QBluetoothUuid();
- QBluetoothUuid(ProtocolUuid uuid);
- QBluetoothUuid(ServiceClassUuid uuid);
- QBluetoothUuid(CharacteristicType uuid);
- QBluetoothUuid(DescriptorType uuid);
- explicit QBluetoothUuid(quint16 uuid);
- explicit QBluetoothUuid(quint32 uuid);
+ constexpr QBluetoothUuid() noexcept {};
+
+ // values below are based on Bluetooth BASE_UUID
+ constexpr QBluetoothUuid(ProtocolUuid uuid) noexcept
+ : QUuid(uuid, 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+ constexpr QBluetoothUuid(ServiceClassUuid uuid) noexcept
+ : QUuid(uuid, 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+ constexpr QBluetoothUuid(CharacteristicType uuid) noexcept
+ : QUuid(uuid, 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+ constexpr QBluetoothUuid(DescriptorType uuid) noexcept
+ : QUuid(uuid, 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+ explicit constexpr QBluetoothUuid(quint16 uuid) noexcept
+ : QUuid(uuid, 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+ explicit constexpr QBluetoothUuid(quint32 uuid) noexcept
+ : QUuid(uuid, 0x0, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb) {};
+
explicit QBluetoothUuid(quint128 uuid);
explicit QBluetoothUuid(const QString &uuid);
QBluetoothUuid(const QBluetoothUuid &uuid);