ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/liblzf/lzf_c.c
(Generate patch)

Comparing liblzf/lzf_c.c (file contents):
Revision 1.6 by pcg, Tue Apr 20 18:11:58 2004 UTC vs.
Revision 1.7 by root, Tue Aug 3 15:37:48 2004 UTC

46 * the hashing function might seem strange, just believe me 46 * the hashing function might seem strange, just believe me
47 * it works ;) 47 * it works ;)
48 */ 48 */
49#define FRST(p) (((p[0]) << 8) + p[1]) 49#define FRST(p) (((p[0]) << 8) + p[1])
50#define NEXT(v,p) (((v) << 8) + p[2]) 50#define NEXT(v,p) (((v) << 8) + p[2])
51#define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) + h*3) & (HSIZE - 1)) 51#define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
52/* 52/*
53 * IDX works because it is very similar to a multiplicative hash, e.g. 53 * IDX works because it is very similar to a multiplicative hash, e.g.
54 * (h * 57321 >> (3*8 - HLOG)) 54 * ((h * 57321 >> (3*8 - HLOG)) & (HSIZE - 1))
55 * the latter is also quite fast on newer CPUs, and sligthly better
56 *
55 * the next one is also quite good, albeit slow ;) 57 * the next one is also quite good, albeit slow ;)
56 * (int)(cos(h & 0xffffff) * 1e6) 58 * (int)(cos(h & 0xffffff) * 1e6)
57 */ 59 */
58 60
59#if 0 61#if 0
60/* original lzv-like hash function */ 62/* original lzv-like hash function, much worse and thus slower */
61# define FRST(p) (p[0] << 5) ^ p[1] 63# define FRST(p) (p[0] << 5) ^ p[1]
62# define NEXT(v,p) ((v) << 5) ^ p[2] 64# define NEXT(v,p) ((v) << 5) ^ p[2]
63# define IDX(h) ((h) & (HSIZE - 1)) 65# define IDX(h) ((h) & (HSIZE - 1))
64#endif 66#endif
65 67

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines