]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Faster keywordCode() implementation by taking advantage of the fact that
authordrh <drh@noemail.net>
Mon, 8 Feb 2016 03:23:46 +0000 (03:23 +0000)
committerdrh <drh@noemail.net>
Mon, 8 Feb 2016 03:23:46 +0000 (03:23 +0000)
the input is always pure ASCII alphabetic and underscore and that the keyword
table is always upper-case.

FossilOrigin-Name: ff406b9701ebe3a01834837f380641c6f0c495bc

manifest
manifest.uuid
tool/mkkeywordhash.c

index 3badb22032c4ea753c1a4ea29514d35a8ea5683c..a3d118431976bd3ce49ae09e2131f0646cca8178 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Demonstrate\sa\smuch\sfaster\ssqlite3GetToken()\sroutine\sby\susing\sa\slookup\stable\nto\smap\sinitial\stoken\scharacters\sinto\sa\scharacter\sclass.\s\sThis\scheck-in\sdoes\nnot\swork\sfor\sEBCDIC.\s\sMore\soptimization\sneeded.
-D 2016-02-08T02:30:50.194
+C Faster\skeywordCode()\simplementation\sby\staking\sadvantage\sof\sthe\sfact\sthat\nthe\sinput\sis\salways\spure\sASCII\salphabetic\sand\sunderscore\sand\sthat\sthe\skeyword\ntable\sis\salways\supper-case.
+D 2016-02-08T03:23:46.173
 F Makefile.in 0a957a57243a3d55e96b1514e22ffae5db9ea116
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc a3f8092763bb5d0057f0f4feb6b7fcc19713e107
@@ -1383,7 +1383,7 @@ F tool/lempar.c 3ec1463a034b37d87d782be5f6b8b10a3b1ecbe7
 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
 F tool/logest.c eef612f8adf4d0993dafed0416064cf50d5d33c6
 F tool/mkautoconfamal.sh a29b14d54302b33fd892958f6895582ea90e4a45
-F tool/mkkeywordhash.c 06ec0b78bd4fa68c12d90ef2bdfe76b039133ff8
+F tool/mkkeywordhash.c 4451824f4f68f8e8d89eba080e0c1a9cf83f7b62
 F tool/mkmsvcmin.tcl d57e6efc9428605f5418d0b235721ddf7b5d9c0b
 F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c
 F tool/mkopcodeh.tcl 385c62d78c38b2d92146dcb5abd319dbbc33506d
@@ -1427,10 +1427,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P ab269e720552483c5617906837e294c1be3e0a57
-R de21eeb460827c84c88aec10967c3b1d
-T *branch * tokenizer-char-class
-T *sym-tokenizer-char-class *
-T -sym-trunk *
+P 9115baa1919584dc8ca25bbff54d3b65748a9631
+R b013689cd0826a67d194ddf9700064de
 U drh
-Z 8982f608f7ca1f17154501e0dba47865
+Z b5dc027d5e497c867b371327464bbd96
index 9b08cb07e922cb16eda627c8cc0fd4c59869e730..290fa630a8a9d69f90c41834313d8c298b7a2a80 100644 (file)
@@ -1 +1 @@
-9115baa1919584dc8ca25bbff54d3b65748a9631
\ No newline at end of file
+ff406b9701ebe3a01834837f380641c6f0c495bc
\ No newline at end of file
index 003ed7d66eff0debe8492e6c2fed5ca758b8f6ea..43455ef97ce2d0e9c8439ae2cec4415e8b7379c6 100644 (file)
@@ -565,20 +565,23 @@ int main(int argc, char **argv){
   }
   printf("%s  };\n", j==0 ? "" : "\n");
 
-  printf("  int h, i;\n");
+  printf("  int h, i, j;\n");
+  printf("  const char *zKW;\n");
   printf("  if( n>=2 ){\n");
   printf("    h = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) %% %d;\n",
           bestSize);
   printf("    for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){\n");
-  printf("      if( aLen[i]==n &&"
-                     " sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){\n");
+  printf("      if( aLen[i]!=n ) continue;\n");
+  printf("      j = 0;\n");
+  printf("      zKW = &zText[aOffset[i]];\n");
+  printf("      while( j<n && (z[j]&~0x20)==zKW[j] ){ j++; }\n");
+  printf("      if( j<n ) continue;\n");
   for(i=0; i<nKeyword; i++){
-    printf("        testcase( i==%d ); /* %s */\n",
+    printf("      testcase( i==%d ); /* %s */\n",
            i, aKeywordTable[i].zOrigName);
   }
-  printf("        *pType = aCode[i];\n");
-  printf("        break;\n");
-  printf("      }\n");
+  printf("      *pType = aCode[i];\n");
+  printf("      break;\n");
   printf("    }\n");
   printf("  }\n");
   printf("  return n;\n");