summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lzf_c.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/lzf_c.c b/lzf_c.c
index 5b42a36..554e996 100644
--- a/lzf_c.c
+++ b/lzf_c.c
@@ -160,10 +160,6 @@ lzf_compress (const void *const in_data, unsigned int in_len,
if (expect_false (op + lit + 1 + 3 >= out_end))
return 0;
- do
- len++;
- while (len < maxlen && ref[len] == ip[len]);
-
if (lit)
{
*op++ = lit - 1;
@@ -173,6 +169,27 @@ lzf_compress (const void *const in_data, unsigned int in_len,
while (++lit);
}
+ for (;;)
+ {
+ if (expect_true (ip < in_end - 2 - 8 && maxlen > 8))
+ {
+ len++; if (ref [len] != ip [len]) break;
+ len++; if (ref [len] != ip [len]) break;
+ len++; if (ref [len] != ip [len]) break;
+ len++; if (ref [len] != ip [len]) break;
+ len++; if (ref [len] != ip [len]) break;
+ len++; if (ref [len] != ip [len]) break;
+ len++; if (ref [len] != ip [len]) break;
+ len++; if (ref [len] != ip [len]) break;
+ }
+
+ do
+ len++;
+ while (len < maxlen && ref[len] == ip[len]);
+
+ break;
+ }
+
len -= 2;
ip++;