]> mj.ucw.cz Git - libucw.git/commitdiff
Oops, the hash function for fingerprints was terribly biased. There should
authorMartin Mares <mj@ucw.cz>
Wed, 11 Jun 2003 13:03:30 +0000 (13:03 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 11 Jun 2003 13:03:30 +0000 (13:03 +0000)
be XOR, not OR. Also, the shifts are meaningless, because the fingerprint
hash is believed to be very well distributed.

Beware, this means that the current mainline is incompatible with string
indices generated by v2.4!  For now, I'm not increasing the index version,
because word matching still works with old indices and I want to profile it.

lib/index.h

index 164383bc43808bae005634c9a5f43559e3678276..cd794c9387298b06de47c3d712045825434a705a 100644 (file)
@@ -105,7 +105,7 @@ void fingerprint(byte *string, struct fingerprint *fp);
 static inline u32
 fp_hash(struct fingerprint *fp)
 {
-  return (fp->hash[0] << 24) | (fp->hash[1] << 16) | (fp->hash[2] << 8) | fp->hash[3];
+  return fp->hash[0] ^ fp->hash[1] ^ fp->hash[2] ^ fp->hash[3];
 }
 
 /* Reading of tagged text (Unicode values, tags mapped to 0x80000000 and higher) */