diff options
Diffstat (limited to 'lzip.h')
-rw-r--r-- | lzip.h | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -30,10 +30,11 @@ public: static const int next[states] = { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 }; st = next[st]; } - - void set_match() { st = ( ( st < 7 ) ? 7 : 10 ); } - void set_rep() { st = ( ( st < 7 ) ? 8 : 11 ); } - void set_short_rep() { st = ( ( st < 7 ) ? 9 : 11 ); } + void set_char1() { st -= ( st < 4 ) ? st : 3; } // for st < 7 + void set_char2() { st -= ( st < 10 ) ? 3 : 6; } // for st >= 7 + void set_match() { st = ( st < 7 ) ? 7 : 10; } + void set_rep() { st = ( st < 7 ) ? 8 : 11; } + void set_short_rep() { st = ( st < 7 ) ? 9 : 11; } }; @@ -147,10 +148,11 @@ public: uint32_t operator[]( const uint8_t byte ) const { return data[byte]; } - void update( uint32_t & crc, const uint8_t byte ) const + void update_byte( uint32_t & crc, const uint8_t byte ) const { crc = data[(crc^byte)&0xFF] ^ ( crc >> 8 ); } - void update( uint32_t & crc, const uint8_t * const buffer, const int size ) const + void update_buf( uint32_t & crc, const uint8_t * const buffer, + const int size ) const { for( int i = 0; i < size; ++i ) crc = data[(crc^buffer[i])&0xFF] ^ ( crc >> 8 ); @@ -192,15 +194,15 @@ struct File_header return sz; } - bool dictionary_size( const int sz ) + bool dictionary_size( const unsigned sz ) { if( sz >= min_dictionary_size && sz <= max_dictionary_size ) { data[5] = real_bits( sz - 1 ); if( sz > min_dictionary_size ) { - const int base_size = 1 << data[5]; - const int wedge = base_size / 16; + const unsigned base_size = 1 << data[5]; + const unsigned wedge = base_size / 16; for( int i = 7; i >= 1; --i ) if( base_size - ( i * wedge ) >= sz ) { data[5] |= ( i << 5 ); break; } |