Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nemequ/liblzf.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Lehmann <schmorpforge@schmorp.de>2005-03-08 22:59:52 +0300
committerMarc Lehmann <schmorpforge@schmorp.de>2005-03-08 22:59:52 +0300
commitab3ef38f0ad51eabc7154f73fa98d972c85e9b45 (patch)
tree82cb3abcd7af9054fa6cd35216c991b89c6df558 /lzf_c.c
parentf3dcfae64dd3f6dbdb62918bdf1e270226f40723 (diff)
*** empty log message ***
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
{