Index: common/image.c =================================================================== RCS file: /cvsroot/crossfire/client/common/image.c,v retrieving revision 1.21 diff -C5 -r1.21 image.c *** common/image.c 23 Feb 2006 20:18:28 -0000 1.21 --- common/image.c 12 Apr 2006 10:46:14 -0000 *************** *** 159,170 **** * we store/look for the correct one in the next bucket. * ******************************************************************************* */ ! /* This should be a prime */ ! #define IMAGE_HASH 5399 Face_Information face_info; char home_dir[MAX_BUF]; --- 159,170 ---- * we store/look for the correct one in the next bucket. * ******************************************************************************* */ ! /* This should be a power of 2 */ ! #define IMAGE_HASH 8192 Face_Information face_info; char home_dir[MAX_BUF]; *************** *** 178,205 **** char *image_name; struct Cache_Entry *cache_entry; } image_cache[IMAGE_HASH]; ! /* This function is basically hasarch from the server, common/arch.c * a few changes - first, we stop processing when we reach the first * . - this is because I'm not sure if hashing .111 at the end of * all the image names will be very useful. */ static uint32 image_hash_name(char *str, int tablesize) { uint32 hash = 0; - int rot = 0; char *p; for (p = str; *p!='\0' && *p != '.'; p++) { ! hash ^= (uint32) *p << rot; ! rot += 2; ! if (rot >= (int)(sizeof(uint32) - sizeof(char)) * 8) ! rot = 0; ! } ! return (hash % tablesize); } /* This function returns an index into the image_cache for * a matching entry, -1 if no match is found. */ --- 178,207 ---- char *image_name; struct Cache_Entry *cache_entry; } image_cache[IMAGE_HASH]; ! /* This function is basically hasharch from the server, common/arch.c * a few changes - first, we stop processing when we reach the first * . - this is because I'm not sure if hashing .111 at the end of * all the image names will be very useful. */ static uint32 image_hash_name(char *str, int tablesize) { uint32 hash = 0; char *p; + /* use the same one-at-a-time hash function the server now uses */ for (p = str; *p!='\0' && *p != '.'; p++) { ! hash += *p; ! hash += hash << 10; ! hash ^= hash >> 6; ! } ! hash += hash << 3; ! hash ^= hash >> 11; ! hash += hash << 15; ! return hash % tablesize; } /* This function returns an index into the image_cache for * a matching entry, -1 if no match is found. */