diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-08-28 11:03:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-28 11:03:12 +0200 |
commit | afcd669d2f6934c2b6076939d7665f791d495994 (patch) | |
tree | b5868b4e26fc52a6b48443847fbd7ef0aafee908 /libraries/murmur2/src/MurmurHash2.h | |
parent | fbf542d2051576ee25556c3b28112eea094da309 (diff) | |
parent | 7b27f200b1f131f0ea3b23433974cbe68eb979bb (diff) | |
download | PrismLauncher-afcd669d2f6934c2b6076939d7665f791d495994.tar.gz PrismLauncher-afcd669d2f6934c2b6076939d7665f791d495994.tar.bz2 PrismLauncher-afcd669d2f6934c2b6076939d7665f791d495994.zip |
Merge pull request #965 from flowln/fat_files_in_memory
Refactor a bit EnsureMetadataTask and calculate hashes in a incremental manner
Diffstat (limited to 'libraries/murmur2/src/MurmurHash2.h')
-rw-r--r-- | libraries/murmur2/src/MurmurHash2.h | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/libraries/murmur2/src/MurmurHash2.h b/libraries/murmur2/src/MurmurHash2.h index c7b83bca..dc2c9681 100644 --- a/libraries/murmur2/src/MurmurHash2.h +++ b/libraries/murmur2/src/MurmurHash2.h @@ -1,30 +1,33 @@ //----------------------------------------------------------------------------- -// 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) +#include <cstdint> +#include <fstream> -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; -typedef unsigned __int64 uint64_t; +#include <functional> -// Other compilers - -#else // defined(_MSC_VER) +//----------------------------------------------------------------------------- -#include <stdint.h> +#define KiB 1024 +#define MiB 1024*KiB -#endif // !defined(_MSC_VER) +uint32_t MurmurHash2( + std::ifstream&& file_stream, + std::size_t buffer_size = 4*MiB, + std::function<bool(char)> filter_out = [](char) { return false; }); -//----------------------------------------------------------------------------- +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); //----------------------------------------------------------------------------- |