summaryrefslogtreecommitdiff
path: root/lzf_c.c
diff options
context:
space:
mode:
authorroot <root>2005-03-08 19:59:52 +0000
committerroot <root>2005-03-08 19:59:52 +0000
commit52d0d80a5d826b0f53ea4c00d2577ea2e4baba8f (patch)
tree82cb3abcd7af9054fa6cd35216c991b89c6df558 /lzf_c.c
parent674872b0d743ecd13cbcecc911ee75e54d9263a8 (diff)
*** empty log message ***rel-1_5
Diffstat (limited to 'lzf_c.c')
-rw-r--r--lzf_c.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/lzf_c.c b/lzf_c.c
index eeb114e..43f8fb5 100644
--- a/lzf_c.c
+++ b/lzf_c.c
@@ -46,8 +46,8 @@
* the hashing function might seem strange, just believe me
* it works ;)
*/
-#define FRST(p) (((p[0]) << 8) + p[1])
-#define NEXT(v,p) (((v) << 8) + p[2])
+#define FRST(p) (((p[0]) << 8) | p[1])
+#define NEXT(v,p) (((v) << 8) | p[2])
#define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
/*
* IDX works because it is very similar to a multiplicative hash, e.g.
@@ -139,13 +139,13 @@ lzf_compress (const void *const in_data, unsigned int in_len,
unsigned int maxlen = in_end - ip - len;
maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;
+ if (op + lit + 1 + 3 >= out_end)
+ return 0;
+
do
len++;
while (len < maxlen && ref[len] == ip[len]);
- if (op + lit + 1 + 3 >= out_end)
- return 0;
-
if (lit)
{
*op++ = lit - 1;
@@ -170,12 +170,22 @@ lzf_compress (const void *const in_data, unsigned int in_len,
*op++ = off;
-#if ULTRA_FAST
+#if ULTRA_FAST || VERY_FAST
ip += len;
+#if VERY_FAST && !ULTRA_FAST
+ --ip;
+#endif
hval = FRST (ip);
+
+ hval = NEXT (hval, ip);
+ htab[IDX (hval)] = ip;
+ ip++;
+
+#if VERY_FAST && !ULTRA_FAST
hval = NEXT (hval, ip);
htab[IDX (hval)] = ip;
ip++;
+#endif
#else
do
{