OLD | NEW |
1 /////////////////////////////////////////////////////////////////////////////// | 1 /////////////////////////////////////////////////////////////////////////////// |
2 // | 2 // |
3 /// \file lz_encoder_hash.h | 3 /// \file lz_encoder_hash.h |
4 /// \brief Hash macros for match finders | 4 /// \brief Hash macros for match finders |
5 // | 5 // |
6 // Author: Igor Pavlov | 6 // Author: Igor Pavlov |
7 // | 7 // |
8 // This file has been put into the public domain. | 8 // This file has been put into the public domain. |
9 // You can do whatever you want with this file. | 9 // You can do whatever you want with this file. |
10 // | 10 // |
(...skipping 21 matching lines...) Expand all Loading... |
32 #define HASH_3_MASK (HASH_3_SIZE - 1) | 32 #define HASH_3_MASK (HASH_3_SIZE - 1) |
33 #define HASH_4_MASK (HASH_4_SIZE - 1) | 33 #define HASH_4_MASK (HASH_4_SIZE - 1) |
34 | 34 |
35 #define FIX_3_HASH_SIZE (HASH_2_SIZE) | 35 #define FIX_3_HASH_SIZE (HASH_2_SIZE) |
36 #define FIX_4_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE) | 36 #define FIX_4_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE) |
37 #define FIX_5_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE + HASH_4_SIZE) | 37 #define FIX_5_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE + HASH_4_SIZE) |
38 | 38 |
39 // Endianness doesn't matter in hash_2_calc() (no effect on the output). | 39 // Endianness doesn't matter in hash_2_calc() (no effect on the output). |
40 #ifdef TUKLIB_FAST_UNALIGNED_ACCESS | 40 #ifdef TUKLIB_FAST_UNALIGNED_ACCESS |
41 # define hash_2_calc() \ | 41 # define hash_2_calc() \ |
42 » » const uint32_t hash_value = *(const uint16_t *)(cur); | 42 » » const uint32_t hash_value = *(const uint16_t *)(cur) |
43 #else | 43 #else |
44 # define hash_2_calc() \ | 44 # define hash_2_calc() \ |
45 const uint32_t hash_value \ | 45 const uint32_t hash_value \ |
46 = (uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8) | 46 = (uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8) |
47 #endif | 47 #endif |
48 | 48 |
49 #define hash_3_calc() \ | 49 #define hash_3_calc() \ |
50 const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \ | 50 const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \ |
51 const uint32_t hash_2_value = temp & HASH_2_MASK; \ | 51 const uint32_t hash_2_value = temp & HASH_2_MASK; \ |
52 const uint32_t hash_value \ | 52 const uint32_t hash_value \ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 #define mt_hash_4_calc() \ | 100 #define mt_hash_4_calc() \ |
101 const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \ | 101 const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \ |
102 const uint32_t hash_2_value = temp & HASH_2_MASK; \ | 102 const uint32_t hash_2_value = temp & HASH_2_MASK; \ |
103 const uint32_t hash_3_value \ | 103 const uint32_t hash_3_value \ |
104 = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \ | 104 = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \ |
105 const uint32_t hash_4_value = (temp ^ ((uint32_t)(cur[2]) << 8) ^ \ | 105 const uint32_t hash_4_value = (temp ^ ((uint32_t)(cur[2]) << 8) ^ \ |
106 (hash_table[cur[3]] << 5)) & HASH_4_MASK | 106 (hash_table[cur[3]] << 5)) & HASH_4_MASK |
107 | 107 |
108 #endif | 108 #endif |
OLD | NEW |