1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 04:23:51 +00:00

Replace djb hash with xxh3.

This commit is contained in:
Bartosz Taudul 2019-11-07 23:52:52 +01:00
parent 17ee1aed5f
commit 5df7444cbb
3 changed files with 11 additions and 22 deletions

View File

@ -186,6 +186,7 @@
<ClInclude Include="..\..\..\server\TracyWorker.hpp" />
<ClInclude Include="..\..\..\server\tracy_flat_hash_map.hpp" />
<ClInclude Include="..\..\..\server\tracy_pdqsort.h" />
<ClInclude Include="..\..\..\server\tracy_xxh3.h" />
<ClInclude Include="..\..\libs\gl3w\GL\gl3w.h" />
<ClInclude Include="..\..\libs\gl3w\GL\glcorearb.h" />
<ClInclude Include="..\..\src\Arimo.hpp" />

View File

@ -299,6 +299,9 @@
<ClInclude Include="..\..\..\server\TracyShortPtr.hpp">
<Filter>server</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\tracy_xxh3.h">
<Filter>server</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Natvis Include="DebugVis.natvis" />

View File

@ -5,6 +5,8 @@
#include <stdint.h>
#include <string.h>
#define XXH_STATIC_LINKING_ONLY
#include "tracy_xxh3.h"
#include "tracy_flat_hash_map.hpp"
namespace tracy
@ -12,32 +14,15 @@ namespace tracy
namespace charutil
{
static inline uint32_t hash( const char* str )
static inline size_t hash( const char* str )
{
uint32_t hash = 5381;
int c;
while( ( c = *str++ ) != 0 )
{
hash = ( ( hash << 5 ) + hash ) ^ c;
}
return hash;
const auto sz = strlen( str );
return XXH3_64bits( str, sz );
}
static inline uint32_t hash( const char* str, size_t sz )
static inline size_t hash( const char* str, size_t sz )
{
uint32_t hash = 5381;
int c;
while( sz > 0 )
{
c = *str++;
hash = ( ( hash << 5 ) + hash ) ^ c;
sz--;
}
return hash;
return XXH3_64bits( str, sz );
}
struct Hasher