From: drh Date: Wed, 28 Sep 2016 20:42:31 +0000 (+0000) Subject: Use Knuth multiplicative hashing for the symbol table. X-Git-Tag: version-3.15.0~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5f33eaa6a4855461d8b596235d66c432ef2ce77c;p=thirdparty%2Fsqlite.git Use Knuth multiplicative hashing for the symbol table. FossilOrigin-Name: cc29ddd6be60bdbf107f285c9eb57d5896ebca2d --- diff --git a/manifest b/manifest index 9899126ad2..600ed2a364 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Two\smore\stypo\sfixes\sin\scomments. -D 2016-09-28T16:05:53.347 +C Use\sKnuth\smultiplicative\shashing\sfor\sthe\ssymbol\stable. +D 2016-09-28T20:42:31.903 F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5151cc64c4c05f3455f4f692ad11410a810d937f @@ -344,7 +344,7 @@ F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c b9ca262f6ad4d030a3cab737ebf9b0b3c8b4ac80 F src/func.c 29cc9acb170ec1387b9f63eb52cd85f8de96c771 F src/global.c 2917bbc488201b791e5f5dd43d8d2a3ccc315da7 -F src/hash.c 55b5fb474100cee0b901edaf203e26c970940f36 +F src/hash.c 63d0ee752a3b92d4695b2b1f5259c4621b2cfebd F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4 F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 @@ -1525,7 +1525,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 5bbd071d57a8048e2ca17bf97761e4f27fc5a6bf -R bf0761c46088be2deeef7ae66a06e596 +P 40c0fb0af678797c39a99853f9f4102464c16f4b +R 781c8f4e56859d80db856b6e4a37be8a U drh -Z f28f9e255c7712d05cf98e2e813edaa6 +Z f77949e5354e55e63daf682f77676620 diff --git a/manifest.uuid b/manifest.uuid index dd204bcb38..58819f70c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -40c0fb0af678797c39a99853f9f4102464c16f4b \ No newline at end of file +cc29ddd6be60bdbf107f285c9eb57d5896ebca2d \ No newline at end of file diff --git a/src/hash.c b/src/hash.c index eea2dd1ac2..62b695a1bb 100644 --- a/src/hash.c +++ b/src/hash.c @@ -56,7 +56,11 @@ static unsigned int strHash(const char *z){ unsigned int h = 0; unsigned char c; while( (c = (unsigned char)*z++)!=0 ){ /*OPTIMIZATION-IF-TRUE*/ - h = (h<<3) ^ h ^ sqlite3UpperToLower[c]; + /* Knuth multiplicative hashing. (Sorting & Searching, p. 510). + ** 0x9e3779b1 is 2654435761 which is the closest prime number to + ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */ + h += sqlite3UpperToLower[c]; + h *= 0x9e3779b1; } return h; }