Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qhash.cpp File Reference
#include <stdlib.h>
#include <stdint.h>
#include "qhash.h"
#include <qbitarray.h>
#include <qstring.h>
#include <qglobal.h>
#include <qbytearray.h>
#include <qdatetime.h>
#include <qbasicatomic.h>
#include <qendian.h>
#include <private/qrandom_p.h>
#include <private/qsimd_p.h>
#include <qcoreapplication.h>
#include <qrandom.h>
#include <private/qlocale_tools_p.h>
#include <array>
#include <limits.h>
#include <assert.h>
+ Include dependency graph for qhash.cpp:

Go to the source code of this file.

Macros

#define _CRT_RAND_S
 
#define Q_DECL_HOT_FUNCTION
 
#define cROUNDS   1
 
#define dROUNDS   2
 
#define ROTL(x, b)   (uint32_t)(((x) << (b)) | ((x) >> (32 - (b))))
 
#define SIPROUND
 

Functions

Q_NEVER_INLINE static Q_DECL_HOT_FUNCTION uint64_t murmurhash (const void *key, uint64_t len, uint64_t seed) noexcept
 
Q_NEVER_INLINE static Q_DECL_HOT_FUNCTION uint siphash (const uint8_t *in, uint inlen, uint seed, uint seed2)
 
size_t qHashBits (const void *p, size_t size, size_t seed) noexcept
 
size_t qHash (QByteArrayView key, size_t seed) noexcept
 
size_t qHash (QStringView key, size_t seed) noexcept
 
size_t qHash (const QBitArray &bitArray, size_t seed) noexcept
 
size_t qHash (QLatin1StringView key, size_t seed) noexcept
 
uint qt_hash (QStringView key, uint chained) noexcept
 

Variables

 QT_BEGIN_NAMESPACE
 
static Q_CONSTINIT HashSeedStorage qt_qhash_seed
 

Macro Definition Documentation

◆ _CRT_RAND_S

#define _CRT_RAND_S

Definition at line 9 of file qhash.cpp.

◆ cROUNDS

#define cROUNDS   1

Definition at line 396 of file qhash.cpp.

◆ dROUNDS

#define dROUNDS   2

Definition at line 397 of file qhash.cpp.

◆ Q_DECL_HOT_FUNCTION

#define Q_DECL_HOT_FUNCTION

Definition at line 47 of file qhash.cpp.

◆ ROTL

#define ROTL (   x,
  b 
)    (uint32_t)(((x) << (b)) | ((x) >> (32 - (b))))

Definition at line 399 of file qhash.cpp.

◆ SIPROUND

#define SIPROUND
Value:
do { \
v0 += v1; \
v1 = ROTL(v1, 7); \
v1 ^= v0; \
v0 = ROTL(v0, 16); \
v2 += v3; \
v3 = ROTL(v3, 8); \
v3 ^= v2; \
v0 += v3; \
v3 = ROTL(v3, 11); \
v3 ^= v0; \
v2 += v1; \
v1 = ROTL(v1, 9); \
v1 ^= v2; \
v2 = ROTL(v2, 16); \
} while (0)
#define ROTL(x, b)
Definition qhash.cpp:399
GLint GLfloat GLfloat GLfloat v2
GLint GLfloat v0
GLint GLfloat GLfloat v1
GLint GLfloat GLfloat GLfloat GLfloat v3
#define v1
#define v0

Definition at line 401 of file qhash.cpp.

Function Documentation

◆ murmurhash()

Q_NEVER_INLINE static Q_DECL_HOT_FUNCTION uint64_t murmurhash ( const void key,
uint64_t  len,
uint64_t  seed 
)
inlinestaticnoexcept

Definition at line 236 of file qhash.cpp.

References seed.

Referenced by QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), and QHash< Key, T >::qHashBits().

+ Here is the caller graph for this function:

◆ qHash() [1/4]

size_t qHash ( const QBitArray bitArray,
size_t  seed 
)
related

Definition at line 966 of file qhash.cpp.

◆ qHash() [2/4]

size_t qHash ( QByteArrayView  key,
size_t  seed 
)
noexcept

Definition at line 956 of file qhash.cpp.

References qHashBits(), and seed.

+ Here is the call graph for this function:

◆ qHash() [3/4]

size_t qHash ( QLatin1StringView  key,
size_t  seed 
)
related

Definition at line 979 of file qhash.cpp.

◆ qHash() [4/4]

size_t qHash ( QStringView  key,
size_t  seed 
)
related

Definition at line 961 of file qhash.cpp.

◆ qHashBits()

size_t qHashBits ( const void p,
size_t  size,
size_t  seed 
)
related

Definition at line 924 of file qhash.cpp.

Referenced by QTlsPrivate::X509CertificateOpenSSL::hash(), qHash(), qHash(), qHash(), qHash(), qHash(), QHash< Key, T >::qHash(), and QStringView::qHash().

+ Here is the caller graph for this function:

◆ qt_hash()

uint qt_hash ( QStringView  key,
uint  chained 
)
noexcept

Private copy of the implementation of the Qt 4 qHash algorithm for strings, (that is, QChar-based arrays, so all QString-like classes), to be used wherever the result is somehow stored or reused across multiple Qt versions. The public qHash implementation can change at any time, therefore one must not rely on the fact that it will always give the same results.

The qt_hash functions must never change their results.

This function can hash discontiguous memory by invoking it on each chunk, passing the previous's result in the next call's chained argument.

Definition at line 1146 of file qhash.cpp.

Referenced by QResourceRoot::findNode(), qt_rcc_compare_hash::operator()(), and RCCFileInfo::writeDataName().

+ Here is the caller graph for this function:

◆ siphash()

Q_NEVER_INLINE static Q_DECL_HOT_FUNCTION uint siphash ( const uint8_t *  in,
uint  inlen,
uint  seed,
uint  seed2 
)
static

Definition at line 420 of file qhash.cpp.

References cROUNDS, dROUNDS, i, k0, k1, QT_WARNING_DISABLE_GCC, seed, and SIPROUND.

Referenced by QHash< Key, T >::qHashBits().

+ Here is the caller graph for this function:

Variable Documentation

◆ QT_BEGIN_NAMESPACE

QT_BEGIN_NAMESPACE
related

Definition at line 54 of file qhash.cpp.

◆ qt_qhash_seed

Q_CONSTINIT HashSeedStorage qt_qhash_seed
static