git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1237
c9e4aea6-c8fd-4c43-8297-
357d70d61c8c
+2004-10-09 Michael Poole <mdpoole@troilus.org>
+
+ * ircd/hash.c: Fix thinko in hash function: It is not indexed
+ simply by character value, so we cannot just remap the values
+ by case.
+
2004-10-05 Michael Poole <mdpoole@troilus.org>
* ircd/hash.c: Replace the old hash function with one based on
2004-10-05 Michael Poole <mdpoole@troilus.org>
* ircd/hash.c: Replace the old hash function with one based on
- /* Now reorder the hash table. To make it case-insensitive, skip
- * upper-case letters, and have lower-case letters write to the
- * corresponding upper-case character.
- */
+ /* Now reorder the hash table. */
for (ii = 0, rand = 0; ii < 256; ii++)
{
for (ii = 0, rand = 0; ii < 256; ii++)
{
- char ch = ii + CHAR_MIN;
- if (ch != ToLower(ch))
- continue;
if (!rand)
rand = ircrandom();
poly = ii + rand % (256 - ii);
jj = crc32hash[ii];
if (!rand)
rand = ircrandom();
poly = ii + rand % (256 - ii);
jj = crc32hash[ii];
- crc32hash[ToUpper(ch) - CHAR_MIN] = crc32hash[ii] = crc32hash[poly];
+ crc32hash[ii] = crc32hash[poly];
crc32hash[poly] = jj;
rand >>= 8;
}
crc32hash[poly] = jj;
rand >>= 8;
}
*/
static HASHREGS strhash(const char *n)
{
*/
static HASHREGS strhash(const char *n)
{
- HASHREGS hash = crc32hash[*n++ & 255];
+ HASHREGS hash = crc32hash[ToLower(*n++) & 255];
- hash = (hash >> 8) ^ crc32hash[(hash ^ *n++) & 255];
+ hash = (hash >> 8) ^ crc32hash[(hash ^ ToLower(*n++)) & 255];
return hash % HASHSIZE;
}
return hash % HASHSIZE;
}