From: Martin Mares Date: Wed, 11 Jun 2003 13:03:30 +0000 (+0000) Subject: Oops, the hash function for fingerprints was terribly biased. There should X-Git-Tag: holmes-import~1256 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=262c15250485395b49e6c99d972906e1b11cfb74;p=libucw.git Oops, the hash function for fingerprints was terribly biased. There should 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. --- diff --git a/lib/index.h b/lib/index.h index 164383bc..cd794c93 100644 --- a/lib/index.h +++ b/lib/index.h @@ -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) */