new hash function is faster than the old

This commit is contained in:
Enno Rehling 2006-02-04 18:53:34 +00:00
parent 939773826b
commit 3cd617fe39
5 changed files with 57 additions and 58 deletions

View File

@ -321,7 +321,6 @@ enum {
R_AURAKULUM, R_AURAKULUM,
R_SEASERPENTHEAD, R_SEASERPENTHEAD,
R_SPHERE_OF_INVISIBILITY, R_SPHERE_OF_INVISIBILITY,
R_TOADSLIME,
R_BAG_OF_HOLDING, R_BAG_OF_HOLDING,
R_SACK_OF_CONSERVATION, R_SACK_OF_CONSERVATION,
R_TACTICCRYSTAL, R_TACTICCRYSTAL,

View File

@ -93,6 +93,8 @@ do_command_i(const struct tnode * keys, void * u, const char * str, struct order
return E_TOK_NOMATCH; return E_TOK_NOMATCH;
} }
struct unit;
struct order;
extern char * getcommand(struct order * ord); extern char * getcommand(struct order * ord);
extern char * unitname(struct unit * u); extern char * unitname(struct unit * u);

View File

@ -61,10 +61,8 @@ unsigned int
hashstring(const char* s) hashstring(const char* s)
{ {
unsigned int key = 0; unsigned int key = 0;
size_t i = strlen(s); while (*s) {
key = key*37 + *s++;
while (i>0) {
key = (s[--i] + key*37);
} }
return key % 0x7FFFFFFF; return key % 0x7FFFFFFF;
} }