[Library] Update zlibng (#1255)

* Update zlibng

* Set cmake path more directly in zlibng to hopefully fix an issue with the build on drone

* I'm dumb, missing / in path

* Mackal helps with a dumb gitignore issue

* Adding all the files, not sure what's ignoring them and im tired of looking

* Some tweaks to zlibng build to hopefully get it to build properly. works on msvc now
This commit is contained in:
Alex
2021-02-23 17:00:26 -08:00
committed by GitHub
parent e6dee96266
commit 2957f5084d
184 changed files with 22029 additions and 11703 deletions
+39 -53
View File
@@ -7,7 +7,6 @@
#include "zbuild.h"
#include "deflate.h"
#include "deflate_p.h"
#include "match_p.h"
#include "functable.h"
/* ===========================================================================
@@ -17,9 +16,11 @@
* new strings in the dictionary only for unmatched strings or for short
* matches. It is used only for the fast compression options.
*/
ZLIB_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
IPos hash_head; /* head of the hash chain */
int bflush; /* set if current block must be flushed */
Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
Pos hash_head; /* head of the hash chain */
int bflush = 0; /* set if current block must be flushed */
int64_t dist;
uint32_t match_len = 0;
for (;;) {
/* Make sure that we always have enough lookahead, except
@@ -28,93 +29,78 @@ ZLIB_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
* string following the next match.
*/
if (s->lookahead < MIN_LOOKAHEAD) {
functable.fill_window(s);
if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
fill_window(s);
if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
return need_more;
}
if (s->lookahead == 0)
if (UNLIKELY(s->lookahead == 0))
break; /* flush the current block */
}
/* Insert the string window[strstart .. strstart+2] in the
* dictionary, and set hash_head to the head of the hash chain:
*/
hash_head = NIL;
if (s->lookahead >= MIN_MATCH) {
hash_head = functable.insert_string(s, s->strstart, 1);
}
hash_head = functable.quick_insert_string(s, s->strstart);
dist = (int64_t)s->strstart - hash_head;
/* Find the longest match, discarding those <= prev_length.
* At this point we have always match_length < MIN_MATCH
*/
if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
/* To simplify the code, we prevent matches with the string
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
/* Find the longest match, discarding those <= prev_length.
* At this point we have always match length < MIN_MATCH
*/
s->match_length = longest_match(s, hash_head);
/* longest_match() sets match_start */
if (dist <= MAX_DIST(s) && dist > 0) {
/* To simplify the code, we prevent matches with the string
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
match_len = functable.longest_match(s, hash_head);
/* longest_match() sets match_start */
}
}
if (s->match_length >= MIN_MATCH) {
check_match(s, s->strstart, s->match_start, s->match_length);
_tr_tally_dist(s, s->strstart - s->match_start, s->match_length - MIN_MATCH, bflush);
if (match_len >= MIN_MATCH) {
check_match(s, s->strstart, s->match_start, match_len);
s->lookahead -= s->match_length;
bflush = zng_tr_tally_dist(s, s->strstart - s->match_start, match_len - MIN_MATCH);
s->lookahead -= match_len;
/* Insert new strings in the hash table only if the match length
* is not too large. This saves time but degrades compression.
*/
if (s->match_length <= s->max_insert_length && s->lookahead >= MIN_MATCH) {
s->match_length--; /* string at strstart already in table */
if (match_len <= s->max_insert_length && s->lookahead >= MIN_MATCH) {
match_len--; /* string at strstart already in table */
s->strstart++;
#ifdef NOT_TWEAK_COMPILER
do {
functable.insert_string(s, s->strstart, 1);
s->strstart++;
/* strstart never exceeds WSIZE-MAX_MATCH, so there are
* always MIN_MATCH bytes ahead.
*/
} while (--s->match_length != 0);
#else
{
functable.insert_string(s, s->strstart, s->match_length);
s->strstart += s->match_length;
s->match_length = 0;
}
#endif
functable.insert_string(s, s->strstart, match_len);
s->strstart += match_len;
} else {
s->strstart += s->match_length;
s->match_length = 0;
s->ins_h = s->window[s->strstart];
#ifndef NOT_TWEAK_COMPILER
s->strstart += match_len;
#if MIN_MATCH != 3
functable.insert_string(s, s->strstart + 2 - MIN_MATCH, MIN_MATCH - 2);
#else
functable.insert_string(s, s->strstart + 2 - MIN_MATCH, 1);
#if MIN_MATCH != 3
#warning Call insert_string() MIN_MATCH-3 more times
#endif
functable.quick_insert_string(s, s->strstart + 2 - MIN_MATCH);
#endif
/* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
* matter since it will be recomputed at next deflate call.
*/
}
match_len = 0;
} else {
/* No match, output a literal byte */
Tracevv((stderr, "%c", s->window[s->strstart]));
_tr_tally_lit(s, s->window[s->strstart], bflush);
bflush = zng_tr_tally_lit(s, s->window[s->strstart]);
s->lookahead--;
s->strstart++;
}
if (bflush)
if (UNLIKELY(bflush))
FLUSH_BLOCK(s, 0);
}
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
if (flush == Z_FINISH) {
if (UNLIKELY(flush == Z_FINISH)) {
FLUSH_BLOCK(s, 1);
return finish_done;
}
if (s->sym_next)
if (UNLIKELY(s->sym_next))
FLUSH_BLOCK(s, 0);
return block_done;
}