diff options
author | flow <flowlnlnln@gmail.com> | 2022-07-23 23:14:49 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-07-24 17:46:53 -0300 |
commit | f95bcf45ad0e537a124f5aa0c7b9e97a78811289 (patch) | |
tree | ef501d49352200ad76671093fe1f9ad82ea8afa2 /libraries/murmur2/src/MurmurHash2.h | |
parent | 15ec1abb6a3acb77b36f14d3ddccc97a8df8c8e1 (diff) | |
download | PrismLauncher-f95bcf45ad0e537a124f5aa0c7b9e97a78811289.tar.gz PrismLauncher-f95bcf45ad0e537a124f5aa0c7b9e97a78811289.tar.bz2 PrismLauncher-f95bcf45ad0e537a124f5aa0c7b9e97a78811289.zip |
feat(libs): add incremental version of murmurhash2 calculation
This does two passes for a given file, which is kinda slow, but I don't
know how else to get the size excluding the filtered ones :<
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'libraries/murmur2/src/MurmurHash2.h')
-rw-r--r-- | libraries/murmur2/src/MurmurHash2.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/libraries/murmur2/src/MurmurHash2.h b/libraries/murmur2/src/MurmurHash2.h index c7b83bca..acea27ea 100644 --- a/libraries/murmur2/src/MurmurHash2.h +++ b/libraries/murmur2/src/MurmurHash2.h @@ -1,30 +1,30 @@ //----------------------------------------------------------------------------- -// MurmurHash2 was written by Austin Appleby, and is placed in the public -// domain. The author hereby disclaims copyright to this source code. +// The original MurmurHash2 was written by Austin Appleby, and is placed in the +// public domain. The author hereby disclaims copyright to this source code. +// +// This was modified as to possibilitate it's usage incrementally. +// Those modifications are also placed in the public domain, and the author of +// such modifications hereby disclaims copyright to this source code. #pragma once -//----------------------------------------------------------------------------- -// Platform-specific functions and macros - -// Microsoft Visual Studio - -#if defined(_MSC_VER) && (_MSC_VER < 1600) - -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; -typedef unsigned __int64 uint64_t; +#include <cstdint> +#include <fstream> -// Other compilers +#include <functional> -#else // defined(_MSC_VER) - -#include <stdint.h> +//----------------------------------------------------------------------------- -#endif // !defined(_MSC_VER) +uint32_t MurmurHash2( + std::ifstream&& file_stream, + std::size_t buffer_size = 4096, + std::function<bool(char)> filter_out = [](char) { return true; }); -//----------------------------------------------------------------------------- +struct IncrementalHashInfo { + uint32_t h; + uint32_t len; +}; -uint64_t MurmurHash2 ( const void* key, int len, uint32_t seed = 1 ); +void FourBytes_MurmurHash2(const unsigned char* data, IncrementalHashInfo& prev); //----------------------------------------------------------------------------- |