From 67091fcbbd23ecb90eee84eb129200a558679c75 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 2 Jan 2017 11:22:01 +0100 Subject: [PATCH] Fix for slowdown on some files - identical_bytes and compressed_stream_size don't have to be the same anymore, as for some files they differ although decompressed bytes match - tolerance for penalty bytes (5*32 bytes) --- precomp.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/precomp.cpp b/precomp.cpp index abfa103..31ebf0a 100644 --- a/precomp.cpp +++ b/precomp.cpp @@ -96,6 +96,7 @@ using namespace std; #define FAST_COPY_WORK_SIGN_DIST 64 // update work sign after (FAST_COPY_WORK_SIGN_DIST * COPY_BUF_SIZE) bytes #define COMP_CHUNK 512 #define IN_BUF_SIZE 65536 //input buffer +#define PENALTY_BYTES_TOLERANCE 160 unsigned char copybuf[COPY_BUF_SIZE]; @@ -5716,7 +5717,7 @@ void try_recompress(FILE* origfile, int comp_level, int mem_level, int windowbit printf ("Identical decompressed bytes: %i of %i\n", identical_bytes_decomp, decomp_bytes_total); } - final_compression_found = (identical_bytes_decomp == decomp_bytes_total) && (penalty_bytes_len == 0) && (identical_bytes == compressed_stream_size); + final_compression_found = (identical_bytes_decomp == decomp_bytes_total) && (penalty_bytes_len < PENALTY_BYTES_TOLERANCE); } best_identical_bytes_decomp = identical_bytes_decomp; @@ -5747,7 +5748,7 @@ void try_recompress_bzip2(FILE* origfile, int level, int& compressed_stream_size printf ("Identical decompressed bytes: %i of %i\n", identical_bytes_decomp, decomp_bytes_total); } - final_compression_found = (identical_bytes_decomp == decomp_bytes_total) && (penalty_bytes_len == 0) && (identical_bytes == compressed_stream_size); + final_compression_found = (identical_bytes_decomp == decomp_bytes_total) && (penalty_bytes_len < PENALTY_BYTES_TOLERANCE); } best_identical_bytes_decomp = identical_bytes_decomp;