diff options
author | root <root> | 2005-03-08 19:59:52 +0000 |
---|---|---|
committer | root <root> | 2005-03-08 19:59:52 +0000 |
commit | 52d0d80a5d826b0f53ea4c00d2577ea2e4baba8f (patch) | |
tree | 82cb3abcd7af9054fa6cd35216c991b89c6df558 /lzf_c.c | |
parent | 674872b0d743ecd13cbcecc911ee75e54d9263a8 (diff) |
*** empty log message ***rel-1_5
Diffstat (limited to 'lzf_c.c')
-rw-r--r-- | lzf_c.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -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 { |