Skip to content

Commit 081691a

Browse files
authored
Merge pull request #2217 from terrelln/cover-redundant
[cover] Remove unnecessary mask and dedup hash functions
2 parents 370933f + 2312b81 commit 081691a

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/dictBuilder/fastcover.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "../common/threading.h"
2222
#include "cover.h"
2323
#include "../common/zstd_internal.h" /* includes zstd.h */
24+
#include "../compress/zstd_compress_internal.h" /* ZSTD_hash*() */
2425
#ifndef ZDICT_STATIC_LINKING_ONLY
2526
#define ZDICT_STATIC_LINKING_ONLY
2627
#endif
@@ -75,25 +76,16 @@ static clock_t g_time = 0;
7576

7677

7778
/*-*************************************
78-
* Hash Functions (matching zstd_compress_internal.h)
79+
* Hash Functions
7980
***************************************/
80-
static const U64 FASTCOVER_prime6bytes = 227718039650203ULL;
81-
static size_t FASTCOVER_hash6(U64 u, U32 h) { return (size_t)(((u << (64-48)) * FASTCOVER_prime6bytes) >> (64-h)) ; }
82-
static size_t FASTCOVER_hash6Ptr(const void* p, U32 h) { return FASTCOVER_hash6(MEM_readLE64(p), h); }
83-
84-
static const U64 FASTCOVER_prime8bytes = 0xCF1BBCDCB7A56463ULL;
85-
static size_t FASTCOVER_hash8(U64 u, U32 h) { return (size_t)(((u) * FASTCOVER_prime8bytes) >> (64-h)) ; }
86-
static size_t FASTCOVER_hash8Ptr(const void* p, U32 h) { return FASTCOVER_hash8(MEM_readLE64(p), h); }
87-
88-
8981
/**
90-
* Hash the d-byte value pointed to by p and mod 2^f
82+
* Hash the d-byte value pointed to by p and mod 2^f into the frequency vector
9183
*/
92-
static size_t FASTCOVER_hashPtrToIndex(const void* p, U32 h, unsigned d) {
84+
static size_t FASTCOVER_hashPtrToIndex(const void* p, U32 f, unsigned d) {
9385
if (d == 6) {
94-
return FASTCOVER_hash6Ptr(p, h) & ((1 << h) - 1);
86+
return ZSTD_hash6Ptr(p, f);
9587
}
96-
return FASTCOVER_hash8Ptr(p, h) & ((1 << h) - 1);
88+
return ZSTD_hash8Ptr(p, f);
9789
}
9890

9991

0 commit comments

Comments
 (0)