From 79fadb350ef29b2cf0f973d552e02f76754d5fa6 Mon Sep 17 00:00:00 2001 From: Emmanuel Marty Date: Sun, 28 Nov 2021 10:01:11 +0100 Subject: [PATCH] Tiny token reduction, ratio increase for some data --- src/shrink_block_v1.c | 8 ++++---- src/shrink_block_v2.c | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/shrink_block_v1.c b/src/shrink_block_v1.c index 32c5c38..a6a28e4 100644 --- a/src/shrink_block_v1.c +++ b/src/shrink_block_v1.c @@ -361,13 +361,12 @@ static int lzsa_optimize_command_count_v1(lzsa_compressor *pCompressor, const un } } - if ((i + pMatch->length) <= nEndOffset && pMatch->offset > 0 && pMatch->length >= MIN_MATCH_SIZE_V1 && + if ((i + pMatch->length) < nEndOffset && pMatch->offset > 0 && pMatch->length >= MIN_MATCH_SIZE_V1 && pBestMatch[i + pMatch->length].offset > 0 && pBestMatch[i + pMatch->length].length >= MIN_MATCH_SIZE_V1 && - (pMatch->length + pBestMatch[i + pMatch->length].length) >= LEAVE_ALONE_MATCH_SIZE && (pMatch->length + pBestMatch[i + pMatch->length].length) <= MAX_VARLEN && - (i + pMatch->length) > pMatch->offset && - (i + pMatch->length) > pBestMatch[i + pMatch->length].offset && + (i + pMatch->length) >= pMatch->offset && + (i + pMatch->length) >= pBestMatch[i + pMatch->length].offset && (i + pMatch->length + pBestMatch[i + pMatch->length].length) <= nEndOffset && !memcmp(pInWindow + i - pMatch->offset + pMatch->length, pInWindow + i + pMatch->length - pBestMatch[i + pMatch->length].offset, @@ -386,6 +385,7 @@ static int lzsa_optimize_command_count_v1(lzsa_compressor *pCompressor, const un pMatch->length += pBestMatch[i + nMatchLen].length; pBestMatch[i + nMatchLen].offset = 0; pBestMatch[i + nMatchLen].length = -1; + nDidReduce = 1; continue; } } diff --git a/src/shrink_block_v2.c b/src/shrink_block_v2.c index 18714e3..a34b904 100644 --- a/src/shrink_block_v2.c +++ b/src/shrink_block_v2.c @@ -857,13 +857,12 @@ static int lzsa_optimize_command_count_v2(lzsa_compressor *pCompressor, const un } } - if ((i + pMatch->length) <= nEndOffset && pMatch->offset > 0 && pMatch->length >= MIN_MATCH_SIZE_V2 && + if ((i + pMatch->length) < nEndOffset && pMatch->offset > 0 && pMatch->length >= MIN_MATCH_SIZE_V2 && pBestMatch[i + pMatch->length].offset > 0 && pBestMatch[i + pMatch->length].length >= MIN_MATCH_SIZE_V2 && - (pMatch->length + pBestMatch[i + pMatch->length].length) >= LEAVE_ALONE_MATCH_SIZE && (pMatch->length + pBestMatch[i + pMatch->length].length) <= MAX_VARLEN && - (i + pMatch->length) > pMatch->offset && - (i + pMatch->length) > pBestMatch[i + pMatch->length].offset && + (i + pMatch->length) >= pMatch->offset && + (i + pMatch->length) >= pBestMatch[i + pMatch->length].offset && (i + pMatch->length + pBestMatch[i + pMatch->length].length) <= nEndOffset && !memcmp(pInWindow + i - pMatch->offset + pMatch->length, pInWindow + i + pMatch->length - pBestMatch[i + pMatch->length].offset,