Fossil SCM
Improved hash function for the diff algorithm.
Commit
173cca0d7d109857801f399dc7a0bd7c5bfdd2b9
Parent
08d970d68fb6d6c…
1 file changed
+4
-2
+4
-2
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -186,17 +186,19 @@ | ||
| 186 | 186 | while( s<k && fossil_isspace(z[s]) ){ s++; } |
| 187 | 187 | for(h=0, x=s; x<k; x++){ |
| 188 | 188 | if( fossil_isspace(z[x]) ){ |
| 189 | 189 | ++numws; |
| 190 | 190 | }else{ |
| 191 | - h = h ^ (h<<2) ^ z[x]; | |
| 191 | + h += z[x]; | |
| 192 | + h *= 0x9e3779b1; | |
| 192 | 193 | } |
| 193 | 194 | } |
| 194 | 195 | k -= numws; |
| 195 | 196 | }else{ |
| 196 | 197 | for(h=0, x=s; x<k; x++){ |
| 197 | - h = h ^ (h<<2) ^ z[x]; | |
| 198 | + h += z[x]; | |
| 199 | + h *= 0x9e3779b1; | |
| 198 | 200 | } |
| 199 | 201 | } |
| 200 | 202 | a[i].indent = s; |
| 201 | 203 | a[i].h = h = (h<<LENGTH_MASK_SZ) | (k-s); |
| 202 | 204 | h2 = h % nLine; |
| 203 | 205 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -186,17 +186,19 @@ | |
| 186 | while( s<k && fossil_isspace(z[s]) ){ s++; } |
| 187 | for(h=0, x=s; x<k; x++){ |
| 188 | if( fossil_isspace(z[x]) ){ |
| 189 | ++numws; |
| 190 | }else{ |
| 191 | h = h ^ (h<<2) ^ z[x]; |
| 192 | } |
| 193 | } |
| 194 | k -= numws; |
| 195 | }else{ |
| 196 | for(h=0, x=s; x<k; x++){ |
| 197 | h = h ^ (h<<2) ^ z[x]; |
| 198 | } |
| 199 | } |
| 200 | a[i].indent = s; |
| 201 | a[i].h = h = (h<<LENGTH_MASK_SZ) | (k-s); |
| 202 | h2 = h % nLine; |
| 203 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -186,17 +186,19 @@ | |
| 186 | while( s<k && fossil_isspace(z[s]) ){ s++; } |
| 187 | for(h=0, x=s; x<k; x++){ |
| 188 | if( fossil_isspace(z[x]) ){ |
| 189 | ++numws; |
| 190 | }else{ |
| 191 | h += z[x]; |
| 192 | h *= 0x9e3779b1; |
| 193 | } |
| 194 | } |
| 195 | k -= numws; |
| 196 | }else{ |
| 197 | for(h=0, x=s; x<k; x++){ |
| 198 | h += z[x]; |
| 199 | h *= 0x9e3779b1; |
| 200 | } |
| 201 | } |
| 202 | a[i].indent = s; |
| 203 | a[i].h = h = (h<<LENGTH_MASK_SZ) | (k-s); |
| 204 | h2 = h % nLine; |
| 205 |