Parameterize the hash function in mkkeywordhash.c. This was an attempt to

find a better hash function, which turned out to not be successful.

FossilOrigin-Name: 2195d731f51a18f917c4299d8f4c7ee7c139c2527f62869d6da171a6d1d89ea6
This commit is contained in:
drh 2020-12-02 02:58:05 +00:00
parent 636f505864
commit bb497fe36d
3 changed files with 21 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Increase\sthe\sversion\snumber\sto\s3.35.0\sto\sbegin\sthe\snext\sdevelopment\scycle.
D 2020-12-02T00:22:09.917
C Parameterize\sthe\shash\sfunction\sin\smkkeywordhash.c.\s\sThis\swas\san\sattempt\sto\nfind\sa\sbetter\shash\sfunction,\swhich\sturned\sout\sto\snot\sbe\ssuccessful.
D 2020-12-02T02:58:05.804
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -1814,7 +1814,7 @@ F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439
F tool/mkautoconfamal.sh f62353eb6c06ab264da027fd4507d09914433dbdcab9cb011cdc18016f1ab3b8
F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650dbe x
F tool/mkctimec.tcl dd183b73ae1c28249669741c250525f0407e579a70482371668fd5f130d9feb3
F tool/mkkeywordhash.c 11a3f3af8e787d0c5ca459ed66fe80fd09e661876506e7b978ec08c19477bdc2
F tool/mkkeywordhash.c 24e4396ae665d985fed9e040e8b748129c1a12d77eeeae7ad4609821c41ba7bf
F tool/mkmsvcmin.tcl 6ecab9fe22c2c8de4d82d4c46797bda3d2deac8e763885f5a38d0c44a895ab33
F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c
F tool/mkopcodeh.tcl 352a4319c0ad869eb26442bf7c3b015aa15594c21f1cce5a6420dbe999367c21
@ -1886,7 +1886,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 55fa22bd403cc8f0973efea898a7cfa3a32b57c7e2a7a4c30c3f2c72d5396f07
R c4c8678c10e3481910a51c944a97bfe0
P edbabaa30823db7c7d169cb93722b5f74bc711359984fb7e139ca9d10fe7dae4
R c0ed84786324d0934b9713477bd4d8aa
U drh
Z becdcb441cd79c3a54faafc3a5147030
Z adef5cc1a128c4fbf04c3cd6ce9dd431

View File

@ -1 +1 @@
edbabaa30823db7c7d169cb93722b5f74bc711359984fb7e139ca9d10fe7dae4
2195d731f51a18f917c4299d8f4c7ee7c139c2527f62869d6da171a6d1d89ea6

View File

@ -381,6 +381,14 @@ static void reorder(int *pFrom){
reorder(&aKeywordTable[i].iNext);
}
/* Parameter to the hash function
*/
#define HASH_OP ^
#define HASH_CC '^'
#define HASH_C0 4
#define HASH_C1 3
#define HASH_C2 1
/*
** This routine does the work. The generated code is printed on standard
** output.
@ -411,8 +419,9 @@ int main(int argc, char **argv){
assert( p->len<sizeof(p->zOrigName) );
memcpy(p->zOrigName, p->zName, p->len+1);
totalLen += p->len;
p->hash = (charMap(p->zName[0])*4) ^
(charMap(p->zName[p->len-1])*3) ^ (p->len*1);
p->hash = (charMap(p->zName[0])*HASH_C0) HASH_OP
(charMap(p->zName[p->len-1])*HASH_C1) HASH_OP
(p->len*HASH_C2);
p->id = i+1;
}
@ -648,8 +657,9 @@ int main(int argc, char **argv){
printf(" int i, j;\n");
printf(" const char *zKW;\n");
printf(" if( n>=2 ){\n");
printf(" i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) %% %d;\n",
bestSize);
printf(" i = ((charMap(z[0])*%d) %c", HASH_C0, HASH_CC);
printf(" (charMap(z[n-1])*%d) %c", HASH_C1, HASH_CC);
printf(" n*%d) %% %d;\n", HASH_C2, bestSize);
printf(" for(i=((int)aKWHash[i])-1; i>=0; i=((int)aKWNext[i])-1){\n");
printf(" if( aKWLen[i]!=n ) continue;\n");
printf(" zKW = &zKWText[aKWOffset[i]];\n");