Skip to content

Commit a3b9b3a

Browse files
committed
don't LZ search if an RLE is already max length
1 parent 82a1849 commit a3b9b3a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compress.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ size_t pack(uint8_t *unpacked, size_t inputsize, uint8_t *packed, int fast) {
116116
}
117117

118118
while (inpos < inputsize) {
119+
// check for a potential RLE
120+
rle = rle_check(unpacked, unpacked + inpos, inputsize, fast);
119121
// check for a potential back reference
120-
if (inpos < inputsize - 3)
122+
if (rle.size < LONG_RUN_SIZE && inpos < inputsize - 3)
121123
backref = ref_search(unpacked, unpacked + inpos, inputsize, fast);
122124
else backref.size = 0;
123-
// and for a potential RLE
124-
rle = rle_check(unpacked, unpacked + inpos, inputsize, fast);
125125

126126
// if the backref is a better candidate, use it
127127
if (backref.size > 3 && backref.size > rle.size) {

0 commit comments

Comments
 (0)