Skip to content

Commit 731802d

Browse files
committed
add a qHash for QUuid
upstream commits: qt/qtbase@55d68a1 Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
1 parent 55313de commit 731802d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/core/plugin/quuid.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -918,4 +918,15 @@ QUuid QUuid::createUuid()
918918
guid; otherwise returns false.
919919
*/
920920

921+
/**
922+
Returns a hash of the QUuid
923+
*/
924+
uint qHash(const QUuid &uuid)
925+
{
926+
return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16)
927+
^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3])
928+
^ ((uuid.data4[4] << 24) | (uuid.data4[5] << 16) | (uuid.data4[6] << 8) | uuid.data4[7]);
929+
}
930+
931+
921932
QT_END_NAMESPACE

src/core/plugin/quuid.h

+2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QUuid &);
185185
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QUuid &);
186186
#endif
187187

188+
Q_CORE_EXPORT uint qHash(const QUuid &uuid);
189+
188190
QT_END_NAMESPACE
189191

190192
QT_END_HEADER

0 commit comments

Comments
 (0)