Move Fast in HuffmanTable to start of struct, given that common case is <= 9 bits

This commit is contained in:
UnknownShadow200 2018-05-21 17:00:28 +10:00
parent 91ab867d5e
commit cdba690aff
2 changed files with 2 additions and 18 deletions

View File

@ -734,22 +734,6 @@ static void Deflate_Lit(DeflateState* state, Int32 lit) {
//Platform_Log1("lit %i", &lit); //Platform_Log1("lit %i", &lit);
} }
Int32 DecodeHack(HuffmanTable* table, Int32 value, Int32* bits) {
UInt32 codeword = 0;
UInt32 i, j;
for (i = 1, j = 0; i < INFLATE_MAX_BITS; i++, j++) {
codeword = (codeword << 1) | ((value >> j) & 1);
if (codeword < table->EndCodewords[i]) {
Int32 offset = table->FirstOffsets[i] + (codeword - table->FirstCodewords[i]);
*bits = i;
return table->Values[offset];
}
}
return -1;
}
static void Deflate_LenDist(DeflateState* state, Int32 len, Int32 dist) { static void Deflate_LenDist(DeflateState* state, Int32 len, Int32 dist) {
Int32 j; Int32 j;
len_base[29] = UInt16_MaxValue; len_base[29] = UInt16_MaxValue;

View File

@ -35,11 +35,11 @@ void ZLibHeader_Read(Stream* s, ZLibHeader* header);
#define INFLATE_WINDOW_MASK 0x7FFFUL #define INFLATE_WINDOW_MASK 0x7FFFUL
typedef struct HuffmanTable_ { typedef struct HuffmanTable_ {
Int16 Fast[1 << INFLATE_FAST_BITS]; /* Fast lookup table for huffman codes */
UInt16 FirstCodewords[INFLATE_MAX_BITS]; /* Starting codeword for each bit length */ UInt16 FirstCodewords[INFLATE_MAX_BITS]; /* Starting codeword for each bit length */
UInt16 EndCodewords[INFLATE_MAX_BITS]; /* (Last codeword + 1) for each bit length. 0 is ignored. */ UInt16 EndCodewords[INFLATE_MAX_BITS]; /* (Last codeword + 1) for each bit length. 0 is ignored. */
UInt16 FirstOffsets[INFLATE_MAX_BITS]; /* Base offset into Values for codewords of each bit length. */ UInt16 FirstOffsets[INFLATE_MAX_BITS]; /* Base offset into Values for codewords of each bit length. */
UInt16 Values[INFLATE_MAX_LITS]; /* Values/Symbols list */ UInt16 Values[INFLATE_MAX_LITS]; /* Values/Symbols list */
Int16 Fast[1 << INFLATE_FAST_BITS]; /* Fast lookup table for huffman codes */
} HuffmanTable; } HuffmanTable;
typedef struct InflateState_ { typedef struct InflateState_ {