mirror of
https://github.com/libretro/RetroArch
synced 2025-04-17 20:43:10 +00:00
Move djb2 to hash.c
This commit is contained in:
parent
58a8004d38
commit
ae41de8d57
@ -31,17 +31,6 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
static INLINE uint32_t djb2(const char *str)
|
|
||||||
{
|
|
||||||
const unsigned char *aux = (const unsigned char*)str;
|
|
||||||
uint32_t hash = 5381;
|
|
||||||
|
|
||||||
while ( *aux )
|
|
||||||
hash = ( hash << 5 ) + hash + *aux++;
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DB_QUERY_ENTRY 0x1c310956U
|
#define DB_QUERY_ENTRY 0x1c310956U
|
||||||
#define DB_QUERY_ENTRY_PUBLISHER 0x125e594dU
|
#define DB_QUERY_ENTRY_PUBLISHER 0x125e594dU
|
||||||
#define DB_QUERY_ENTRY_DEVELOPER 0xcbd89be5U
|
#define DB_QUERY_ENTRY_DEVELOPER 0xcbd89be5U
|
||||||
@ -68,7 +57,7 @@ int database_info_build_query(char *s, size_t len,
|
|||||||
|
|
||||||
strlcpy(s, "{'", len);
|
strlcpy(s, "{'", len);
|
||||||
|
|
||||||
value = djb2(label);
|
value = djb2_calculate(label);
|
||||||
|
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
@ -210,7 +199,7 @@ static int database_cursor_iterate(libretrodb_cursor_t *cur,
|
|||||||
if (!key || !val)
|
if (!key || !val)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
value = djb2(key->string.buff);
|
value = djb2_calculate(key->string.buff);
|
||||||
|
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
|
11
hash.c
11
hash.c
@ -522,3 +522,14 @@ error:
|
|||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t djb2_calculate(const char *str)
|
||||||
|
{
|
||||||
|
const unsigned char *aux = (const unsigned char*)str;
|
||||||
|
uint32_t hash = 5381;
|
||||||
|
|
||||||
|
while ( *aux )
|
||||||
|
hash = ( hash << 5 ) + hash + *aux++;
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user