gzip: code shrink
function old new delta fill_window_if_needed - 238 +238 deflate 924 907 -17 pack_gzip 809 790 -19 fill_window 216 - -216 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/2 up/down: 238/-252) Total: -14 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
c6d2a26fac
commit
9c499a5af4
@ -312,25 +312,24 @@ struct globals {
|
|||||||
#define nice_match (G1.nice_match)
|
#define nice_match (G1.nice_match)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
lng block_start;
|
|
||||||
|
|
||||||
/* window position at the beginning of the current output block. Gets
|
/* window position at the beginning of the current output block. Gets
|
||||||
* negative when the window is moved backwards.
|
* negative when the window is moved backwards.
|
||||||
*/
|
*/
|
||||||
|
lng block_start;
|
||||||
|
|
||||||
unsigned ins_h; /* hash index of string to be inserted */
|
unsigned ins_h; /* hash index of string to be inserted */
|
||||||
|
|
||||||
#define H_SHIFT ((HASH_BITS+MIN_MATCH-1) / MIN_MATCH)
|
|
||||||
/* Number of bits by which ins_h and del_h must be shifted at each
|
/* Number of bits by which ins_h and del_h must be shifted at each
|
||||||
* input step. It must be such that after MIN_MATCH steps, the oldest
|
* input step. It must be such that after MIN_MATCH steps, the oldest
|
||||||
* byte no longer takes part in the hash key, that is:
|
* byte no longer takes part in the hash key, that is:
|
||||||
* H_SHIFT * MIN_MATCH >= HASH_BITS
|
* H_SHIFT * MIN_MATCH >= HASH_BITS
|
||||||
*/
|
*/
|
||||||
|
#define H_SHIFT ((HASH_BITS+MIN_MATCH-1) / MIN_MATCH)
|
||||||
unsigned prev_length;
|
|
||||||
|
|
||||||
/* Length of the best match at previous step. Matches not greater than this
|
/* Length of the best match at previous step. Matches not greater than this
|
||||||
* are discarded. This is used in the lazy match evaluation.
|
* are discarded. This is used in the lazy match evaluation.
|
||||||
*/
|
*/
|
||||||
|
unsigned prev_length;
|
||||||
|
|
||||||
unsigned strstart; /* start of string to insert */
|
unsigned strstart; /* start of string to insert */
|
||||||
unsigned match_start; /* start of matching string */
|
unsigned match_start; /* start of matching string */
|
||||||
@ -347,18 +346,17 @@ struct globals {
|
|||||||
unsigned insize; /* valid bytes in l_buf */
|
unsigned insize; /* valid bytes in l_buf */
|
||||||
#endif
|
#endif
|
||||||
unsigned outcnt; /* bytes in output buffer */
|
unsigned outcnt; /* bytes in output buffer */
|
||||||
|
|
||||||
smallint eofile; /* flag set at end of input file */
|
smallint eofile; /* flag set at end of input file */
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Local data used by the "bit string" routines.
|
* Local data used by the "bit string" routines.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned short bi_buf;
|
|
||||||
|
|
||||||
/* Output buffer. bits are inserted starting at the bottom (least significant
|
/* Output buffer. bits are inserted starting at the bottom (least significant
|
||||||
* bits).
|
* bits).
|
||||||
*/
|
*/
|
||||||
|
unsigned short bi_buf;
|
||||||
|
|
||||||
#undef BUF_SIZE
|
#undef BUF_SIZE
|
||||||
#define BUF_SIZE (8 * sizeof(G1.bi_buf))
|
#define BUF_SIZE (8 * sizeof(G1.bi_buf))
|
||||||
|
|
||||||
@ -662,6 +660,12 @@ static void fill_window(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Both users fill window with the same loop: */
|
||||||
|
static void fill_window_if_needed(void)
|
||||||
|
{
|
||||||
|
while (G1.lookahead < MIN_LOOKAHEAD && !G1.eofile)
|
||||||
|
fill_window();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
@ -1894,8 +1898,7 @@ static NOINLINE ulg deflate(void)
|
|||||||
* for the next match, plus MIN_MATCH bytes to insert the
|
* for the next match, plus MIN_MATCH bytes to insert the
|
||||||
* string following the next match.
|
* string following the next match.
|
||||||
*/
|
*/
|
||||||
while (G1.lookahead < MIN_LOOKAHEAD && !G1.eofile)
|
fill_window_if_needed();
|
||||||
fill_window();
|
|
||||||
}
|
}
|
||||||
if (match_available)
|
if (match_available)
|
||||||
ct_tally(0, G1.window[G1.strstart - 1]);
|
ct_tally(0, G1.window[G1.strstart - 1]);
|
||||||
@ -1948,8 +1951,7 @@ static void lm_init(ush * flagsp)
|
|||||||
/* Make sure that we always have enough lookahead. This is important
|
/* Make sure that we always have enough lookahead. This is important
|
||||||
* if input comes from a device such as a tty.
|
* if input comes from a device such as a tty.
|
||||||
*/
|
*/
|
||||||
while (G1.lookahead < MIN_LOOKAHEAD && !G1.eofile)
|
fill_window_if_needed();
|
||||||
fill_window();
|
|
||||||
|
|
||||||
//G1.ins_h = 0; // globals are zeroed in pack_gzip()
|
//G1.ins_h = 0; // globals are zeroed in pack_gzip()
|
||||||
for (j = 0; j < MIN_MATCH - 1; j++)
|
for (j = 0; j < MIN_MATCH - 1; j++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user