4040#define HASHBASE 107927
4141
4242struct spanhash {
43- unsigned long hashval ;
44- unsigned long cnt ;
43+ unsigned int hashval ;
44+ unsigned int cnt ;
4545};
4646struct spanhash_top {
4747 int alloc_log2 ;
@@ -50,7 +50,7 @@ struct spanhash_top {
5050};
5151
5252static struct spanhash * spanhash_find (struct spanhash_top * top ,
53- unsigned long hashval )
53+ unsigned int hashval )
5454{
5555 int sz = 1 << top -> alloc_log2 ;
5656 int bucket = hashval & (sz - 1 );
@@ -99,7 +99,7 @@ static struct spanhash_top *spanhash_rehash(struct spanhash_top *orig)
9999}
100100
101101static struct spanhash_top * add_spanhash (struct spanhash_top * top ,
102- unsigned long hashval , int cnt )
102+ unsigned int hashval , int cnt )
103103{
104104 int bucket , lim ;
105105 struct spanhash * h ;
@@ -125,10 +125,10 @@ static struct spanhash_top *add_spanhash(struct spanhash_top *top,
125125 }
126126}
127127
128- static struct spanhash_top * hash_chars (unsigned char * buf , unsigned long sz )
128+ static struct spanhash_top * hash_chars (unsigned char * buf , unsigned int sz )
129129{
130130 int i , n ;
131- unsigned long accum1 , accum2 , hashval ;
131+ unsigned int accum1 , accum2 , hashval ;
132132 struct spanhash_top * hash ;
133133
134134 i = INITIAL_HASH_SIZE ;
@@ -140,10 +140,11 @@ static struct spanhash_top *hash_chars(unsigned char *buf, unsigned long sz)
140140 n = 0 ;
141141 accum1 = accum2 = 0 ;
142142 while (sz ) {
143- unsigned long c = * buf ++ ;
143+ unsigned int c = * buf ++ ;
144+ unsigned int old_1 = accum1 ;
144145 sz -- ;
145- accum1 = (accum1 << 7 ) | (accum2 >> 25 );
146- accum2 = (accum2 << 7 ) | ( accum1 >> 25 );
146+ accum1 = (accum1 << 7 ) ^ (accum2 >> 25 );
147+ accum2 = (accum2 << 7 ) ^ ( old_1 >> 25 );
147148 accum1 += c ;
148149 if (++ n < 64 && c != '\n' )
149150 continue ;
0 commit comments