=========================================================================== * Compress as much as possible from the input stream, return the current * block state. * This function does not perform lazy evaluation of matches and inserts * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */
(s, flush)
| 1827 | * matches. It is used only for the fast compression options. |
| 1828 | */ |
| 1829 | local block_state deflate_fast(s, flush) |
| 1830 | deflate_state *s; |
| 1831 | int flush; |
| 1832 | { |
| 1833 | IPos hash_head; /* head of the hash chain */ |
| 1834 | int bflush; /* set if current block must be flushed */ |
| 1835 | |
| 1836 | for (;;) { |
| 1837 | /* Make sure that we always have enough lookahead, except |
| 1838 | * at the end of the input file. We need MAX_MATCH bytes |
| 1839 | * for the next match, plus MIN_MATCH bytes to insert the |
| 1840 | * string following the next match. |
| 1841 | */ |
| 1842 | if (s->lookahead < MIN_LOOKAHEAD) { |
| 1843 | fill_window(s); |
| 1844 | if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { |
| 1845 | return need_more; |
| 1846 | } |
| 1847 | if (s->lookahead == 0) break; /* flush the current block */ |
| 1848 | } |
| 1849 | |
| 1850 | /* Insert the string window[strstart .. strstart+2] in the |
| 1851 | * dictionary, and set hash_head to the head of the hash chain: |
| 1852 | */ |
| 1853 | hash_head = NIL; |
| 1854 | if (s->lookahead >= MIN_MATCH) { |
| 1855 | INSERT_STRING(s, s->strstart, hash_head); |
| 1856 | } |
| 1857 | |
| 1858 | /* Find the longest match, discarding those <= prev_length. |
| 1859 | * At this point we have always match_length < MIN_MATCH |
| 1860 | */ |
| 1861 | if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { |
| 1862 | /* To simplify the code, we prevent matches with the string |
| 1863 | * of window index 0 (in particular we have to avoid a match |
| 1864 | * of the string with itself at the start of the input file). |
| 1865 | */ |
| 1866 | s->match_length = longest_match (s, hash_head); |
| 1867 | /* longest_match() sets match_start */ |
| 1868 | } |
| 1869 | if (s->match_length >= MIN_MATCH) { |
| 1870 | check_match(s, s->strstart, s->match_start, s->match_length); |
| 1871 | |
| 1872 | _tr_tally_dist(s, s->strstart - s->match_start, |
| 1873 | s->match_length - MIN_MATCH, bflush); |
| 1874 | |
| 1875 | s->lookahead -= s->match_length; |
| 1876 | |
| 1877 | /* Insert new strings in the hash table only if the match length |
| 1878 | * is not too large. This saves time but degrades compression. |
| 1879 | */ |
| 1880 | #ifndef FASTEST |
| 1881 | if (s->match_length <= s->max_insert_length && |
| 1882 | s->lookahead >= MIN_MATCH) { |
| 1883 | s->match_length--; /* string at strstart already in table */ |
| 1884 | do { |
| 1885 | s->strstart++; |
| 1886 | INSERT_STRING(s, s->strstart, hash_head); |
nothing calls this directly
no test coverage detected