From a3b9b3a5efe3f616f71755248168efc87d21fa8f Mon Sep 17 00:00:00 2001 From: devinacker Date: Fri, 15 Nov 2013 17:09:54 -0500 Subject: [PATCH] don't LZ search if an RLE is already max length --- compress.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compress.c b/compress.c index c6e6917..c48f529 100644 --- a/compress.c +++ b/compress.c @@ -116,12 +116,12 @@ size_t pack(uint8_t *unpacked, size_t inputsize, uint8_t *packed, int fast) { } while (inpos < inputsize) { + // check for a potential RLE + rle = rle_check(unpacked, unpacked + inpos, inputsize, fast); // check for a potential back reference - if (inpos < inputsize - 3) + if (rle.size < LONG_RUN_SIZE && inpos < inputsize - 3) backref = ref_search(unpacked, unpacked + inpos, inputsize, fast); else backref.size = 0; - // and for a potential RLE - rle = rle_check(unpacked, unpacked + inpos, inputsize, fast); // if the backref is a better candidate, use it if (backref.size > 3 && backref.size > rle.size) {