Move core/hash to core/util;

This commit is contained in:
bjorn 2020-05-19 13:49:40 -06:00
parent 17a0205df7
commit 75e26f0051
10 changed files with 12 additions and 17 deletions

View File

@ -3,7 +3,6 @@
#include <lualib.h>
#include <stdint.h>
#include <string.h>
#include "core/hash.h"
#include "core/util.h"
#pragma once

View File

@ -3,12 +3,3 @@
#pragma once
// FNV1a
static LOVR_INLINE uint64_t hash64(const void* data, size_t length) {
const uint8_t* bytes = (const uint8_t*) data;
uint64_t hash = 0xcbf29ce484222325;
for (size_t i = 0; i < length; i++) {
hash = (hash ^ bytes[i]) * 0x100000001b3;
}
return hash;
}

View File

@ -1,5 +1,6 @@
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#pragma once
@ -45,3 +46,13 @@ void lovrSetErrorCallback(errorFn* callback, void* context);
void LOVR_NORETURN lovrThrow(const char* format, ...);
#define lovrAssert(c, ...) if (!(c)) { lovrThrow(__VA_ARGS__); }
// FNV1a
static LOVR_INLINE uint64_t hash64(const void* data, size_t length) {
const uint8_t* bytes = (const uint8_t*) data;
uint64_t hash = 0xcbf29ce484222325;
for (size_t i = 0; i < length; i++) {
hash = (hash ^ bytes[i]) * 0x100000001b3;
}
return hash;
}

View File

@ -1,7 +1,6 @@
#include "data/modelData.h"
#include "data/blob.h"
#include "data/textureData.h"
#include "core/hash.h"
#include "core/maf.h"
#include "core/ref.h"
#include "lib/jsmn/jsmn.h"

View File

@ -2,7 +2,6 @@
#include "data/blob.h"
#include "data/textureData.h"
#include "core/arr.h"
#include "core/hash.h"
#include "core/maf.h"
#include "core/map.h"
#include "core/ref.h"

View File

@ -1,8 +1,8 @@
#include "filesystem/filesystem.h"
#include "core/arr.h"
#include "core/fs.h"
#include "core/hash.h"
#include "core/map.h"
#include "core/util.h"
#include "core/zip.h"
#include "lib/stb/stb_image.h"
#include <string.h>

View File

@ -3,7 +3,6 @@
#include "data/rasterizer.h"
#include "data/textureData.h"
#include "core/arr.h"
#include "core/hash.h"
#include "core/map.h"
#include "core/ref.h"
#include "core/utf.h"

View File

@ -8,7 +8,6 @@
#include "resources/shaders.h"
#include "data/modelData.h"
#include "math/math.h"
#include "core/hash.h"
#include "core/ref.h"
#include <math.h>
#include <limits.h>

View File

@ -4,7 +4,6 @@
#include "graphics/canvas.h"
#include "graphics/texture.h"
#include "core/arr.h"
#include "core/hash.h"
#include "core/maf.h"
#include "core/map.h"
#include "core/ref.h"

View File

@ -1,7 +1,6 @@
#include "thread/thread.h"
#include "thread/channel.h"
#include "core/arr.h"
#include "core/hash.h"
#include "core/map.h"
#include "core/ref.h"
#include "core/util.h"