Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qhash.cpp File Reference

(4c286d6f6c746d41ad7a95ef1f28d1cccf244649)

#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 ROTL(x, b)   (((x) << (b)) | ((x) >> (sizeof(x) * 8 - (b))))
 
#define SIPROUND
 
#define SIPROUND
 

Enumerations

enum  ZeroExtension { None = 0 , ByteToWord = 1 }
 

Functions

QT_BEGIN_NAMESPACE void qt_from_latin1 (char16_t *dst, const char *str, size_t size) noexcept
 
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 size_t siphash (const uint8_t *in, size_t inlen, size_t seed, size_t seed2)
 
template<ZeroExtension = None>
static size_t qHashBits_fallback (const uchar *p, size_t size, size_t seed, size_t seed2) noexcept
 
template<>
size_t qHashBits_fallback< None > (const uchar *p, size_t size, size_t seed, size_t seed2) noexcept
 
template<>
size_t qHashBits_fallback< ByteToWord > (const uchar *data, size_t size, size_t seed, size_t seed2) noexcept
 
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

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.

◆ Q_DECL_HOT_FUNCTION

#define Q_DECL_HOT_FUNCTION

Definition at line 47 of file qhash.cpp.

◆ ROTL

#define ROTL ( x,
b )   (((x) << (b)) | ((x) >> (sizeof(x) * 8 - (b))))

Definition at line 292 of file qhash.cpp.

◆ SIPROUND [1/2]

#define SIPROUND
Value:
do { \
v0 += v1; \
v1 = ROTL(v1, 13); \
v1 ^= v0; \
v0 = ROTL(v0, 32); \
v2 += v3; \
v3 = ROTL(v3, 16); \
v3 ^= v2; \
v0 += v3; \
v3 = ROTL(v3, 21); \
v3 ^= v0; \
v2 += v1; \
v1 = ROTL(v1, 17); \
v1 ^= v2; \
v2 = ROTL(v2, 32); \
} while (0)
#define ROTL(x, b)
Definition qhash.cpp:292
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 294 of file qhash.cpp.

◆ SIPROUND [2/2]

#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)

Definition at line 294 of file qhash.cpp.

Enumeration Type Documentation

◆ ZeroExtension

Enumerator
None 
ByteToWord 

Definition at line 530 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 240 of file qhash.cpp.

References seed.

Referenced by QHash< Key, T >::qHash(), QHash< Key, T >::qHash(), qHashBits_fallback< ByteToWord >(), and qHashBits_fallback< None >().

+ Here is the caller graph for this function:

◆ qHash() [1/4]

size_t qHash ( const QBitArray & bitArray,
size_t seed )
related

Definition at line 1125 of file qhash.cpp.

◆ qHash() [2/4]

size_t qHash ( QByteArrayView key,
size_t seed )
noexcept

Definition at line 1114 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 1139 of file qhash.cpp.

◆ qHash() [4/4]

size_t qHash ( QStringView key,
size_t seed )
related

Definition at line 1119 of file qhash.cpp.

◆ qHashBits()

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

Definition at line 1089 of file qhash.cpp.

Referenced by QTlsPrivate::X509CertificateOpenSSL::hash(), qHash(), qHash(), qHash(), qHash(), qHash(), and QStringView::qHash().

+ Here is the caller graph for this function:

◆ qHashBits_fallback()

template<ZeroExtension = None>
static size_t qHashBits_fallback ( const uchar * p,
size_t size,
size_t seed,
size_t seed2 )
staticnoexcept

◆ qHashBits_fallback< ByteToWord >()

template<>
size_t qHashBits_fallback< ByteToWord > ( const uchar * data,
size_t size,
size_t seed,
size_t seed2 )
noexcept

Definition at line 545 of file qhash.cpp.

References murmurhash(), qt_from_latin1(), QT_POINTER_SIZE, seed, and siphash().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qHashBits_fallback< None >()

template<>
size_t qHashBits_fallback< None > ( const uchar * p,
size_t size,
size_t seed,
size_t seed2 )
noexcept

Definition at line 537 of file qhash.cpp.

References murmurhash(), QT_POINTER_SIZE, seed, and siphash().

+ Here is the call graph for this function:

◆ qt_from_latin1()

QT_BEGIN_NAMESPACE void qt_from_latin1 ( char16_t * dst,
const char * str,
size_t size )
noexcept

Definition at line 920 of file qstring.cpp.

References i, and str.

Referenced by QAbstractConcatenable::appendLatin1To(), argToQStringImpl(), QLatin1::convertToUnicode(), QString::fromLatin1(), insert_helper(), QString::operator=(), qHashBits_fallback< ByteToWord >(), and qt_from_latin1_to_qvla().

+ 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 1325 of file qhash.cpp.

Referenced by 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 size_t siphash ( const uint8_t * in,
size_t inlen,
size_t seed,
size_t seed2 )
static

Definition at line 522 of file qhash.cpp.

References seed.

Referenced by qHashBits_fallback< ByteToWord >(), and qHashBits_fallback< None >().

+ Here is the caller graph for this function:

Variable Documentation

◆ qt_qhash_seed

Q_CONSTINIT HashSeedStorage qt_qhash_seed
static