diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2015-03-30 17:34:15 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2015-03-30 17:34:15 (GMT) |
commit | 6c69dc176c318fba721fa8adade53f3e413cac52 (patch) | |
tree | 2c1d73f7ae359a035d2d9ad11611535a29a4d5a7 /lib/lz4.c | |
parent | 44793b8be9f18bb51f524b3a210de11bb0df6654 (diff) | |
download | lz4-6c69dc176c318fba721fa8adade53f3e413cac52.zip lz4-6c69dc176c318fba721fa8adade53f3e413cac52.tar.gz lz4-6c69dc176c318fba721fa8adade53f3e413cac52.tar.bz2 |
faster compression in 64 bits mode
Diffstat (limited to 'lib/lz4.c')
-rw-r--r-- | lib/lz4.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -464,7 +464,24 @@ static U32 LZ4_hashSequence(U32 sequence, tableType_t const tableType) return (((sequence) * 2654435761U) >> ((MINMATCH*8)-LZ4_HASHLOG)); } -static U32 LZ4_hashPosition(const BYTE* p, tableType_t tableType) { return LZ4_hashSequence(LZ4_read32(p), tableType); } +static const U64 prime5bytes = 889523592379ULL; +static U32 LZ4_hashSequence64(size_t sequence, tableType_t const tableType) +{ + const U32 hashLog = (tableType == byU16) ? LZ4_HASHLOG+1 : LZ4_HASHLOG; + const U32 hashMask = (1<<hashLog) - 1; + return ((sequence * prime5bytes) >> (40 - hashLog)) & hashMask; +} + +static U32 LZ4_hashSequenceT(size_t sequence, tableType_t const tableType) +{ + if (LZ4_64bits()) + return LZ4_hashSequence64(sequence, tableType); + return LZ4_hashSequence((U32)sequence, tableType); +} + +static U32 LZ4_hashPosition(const void* p, tableType_t tableType) { return LZ4_hashSequenceT(LZ4_read_ARCH(p), tableType); } + +//static U32 LZ4_hashPosition(const BYTE* p, tableType_t tableType) { return LZ4_hashSequence(LZ4_read32(p), tableType); } static void LZ4_putPositionOnHash(const BYTE* p, U32 h, void* tableBase, tableType_t const tableType, const BYTE* srcBase) { |