summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2004-08-03 15:37:48 +0000
committerroot <root>2004-08-03 15:37:48 +0000
commitb26af6a3938b12c5899e4792b6214f20362bd8cc (patch)
tree246c5baec133b3f986734371cec1fce75dcf012b
parent87c2b1de373fd1b43a870f66bf3aa97260d40355 (diff)
*** empty log message ***
-rw-r--r--Changes3
-rw-r--r--lzf_c.c8
2 files changed, 8 insertions, 3 deletions
diff --git a/Changes b/Changes
index d94501c..97dd3fb 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+1.4
+ - very very slight tuning of the hashing function.
+
1.3 Thu Mar 25 15:41:17 CET 2004
- changed license of lzf core code to explicitly allow
relicensing under the GPLv2.
diff --git a/lzf_c.c b/lzf_c.c
index 3ffbc9f..da6b926 100644
--- a/lzf_c.c
+++ b/lzf_c.c
@@ -48,16 +48,18 @@
*/
#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*3) & (HSIZE - 1))
+#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.
- * (h * 57321 >> (3*8 - HLOG))
+ * ((h * 57321 >> (3*8 - HLOG)) & (HSIZE - 1))
+ * the latter is also quite fast on newer CPUs, and sligthly better
+ *
* the next one is also quite good, albeit slow ;)
* (int)(cos(h & 0xffffff) * 1e6)
*/
#if 0
-/* original lzv-like hash function */
+/* original lzv-like hash function, much worse and thus slower */
# define FRST(p) (p[0] << 5) ^ p[1]
# define NEXT(v,p) ((v) << 5) ^ p[2]
# define IDX(h) ((h) & (HSIZE - 1))