]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Small performance improvement and size reduction by recognizing that no
authordrh <>
Mon, 19 Jun 2023 20:54:49 +0000 (20:54 +0000)
committerdrh <>
Mon, 19 Jun 2023 20:54:49 +0000 (20:54 +0000)
SQL keywords have less than 2 characters.

FossilOrigin-Name: 6b3d25b7982623ab4b25161aff9ab44778e136069043ab425543597c42c98ae5

manifest
manifest.uuid
src/tokenize.c
tool/mkkeywordhash.c

index a76933d6efde95f1f522d2fe83c9275ef096abaf..83543ab78b125442c42e054be98cf177116e310d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\slarge\sinteger\sconstants\sso\sthat\sthey\swork\son\solder\sC\scompilers.
-D 2023-06-19T13:09:16.199
+C Small\sperformance\simprovement\sand\ssize\sreduction\sby\srecognizing\sthat\sno\nSQL\skeywords\shave\sless\sthan\s2\scharacters.
+D 2023-06-19T20:54:49.547
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -698,7 +698,7 @@ F src/test_windirent.h da2e5b73c32d09905fbdd00f27cd802212a32a58ead882736fe4f5eb7
 F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f
 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
-F src/tokenize.c 1305797eab3542a0896b552c6e7669c972c1468e11e92b370533c1f37a37082b
+F src/tokenize.c 0fb405f9adf3f757c26bfc1ae6d58ac5dccbb918917ba9e5ef0e6673a06563d3
 F src/treeview.c 1d52fbc4e97161e65858d36e3424ea6e3fc045dd8a679c82b4b9593dc30de3bd
 F src/trigger.c ad6ab9452715fa9a8075442e15196022275b414b9141b566af8cdb7a1605f2b0
 F src/update.c cff5ce391a6ffb2125ed7b5d44f3ce1f16af87ad8b9cee1c62bad1ee87d496ed
@@ -1964,7 +1964,7 @@ F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a19
 F tool/mkautoconfamal.sh f62353eb6c06ab264da027fd4507d09914433dbdcab9cb011cdc18016f1ab3b8
 F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650dbe x
 F tool/mkctimec.tcl 38e3db33210a200aae791635125052a643a27aa0619a0debf19aa9c55e1b2dde x
-F tool/mkkeywordhash.c 9822bd1f58a70e5f84179df3045bba4791df69180e991bec88662703f2e93761
+F tool/mkkeywordhash.c b9faa0ae7e14e4dbbcd951cddd786bf46b8a65bb07b129ba8c0cfade723aaffd
 F tool/mkmsvcmin.tcl 8897d515ef7f94772322db95a3b6fce6c614d84fe0bdd06ba5a1c786351d5a1d
 F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef
 F tool/mkopcodeh.tcl 769d9e6a8b462323150dc13a8539d6064664b72974f7894befe2491cc73e05cd
@@ -2040,8 +2040,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P bc4d20f362925e4ce5c79f0d7a27a8e9bbac92525bd4cea2ae983798e3f8c37d
-R 4f624e24f6c2ab94a4c616a97b2a4cbc
+P 3c94f87806a8b408d8204fc7deec16d01c085ee199ff21a1f20b6346ce816cfe
+R 15f717adc06c57cdc873049afed42495
 U drh
-Z d7b617717e187efbbfc027ed7ee0c3f2
+Z 6f59dca549ea3d00f113d41a45951fb1
 # Remove this line to create a well-formed Fossil manifest.
index f584082f2d9a070fae3222358f40758fcb45df14..c32f3cea65d1a3e0414d58dff7d258af84fe2dc7 100644 (file)
@@ -1 +1 @@
-3c94f87806a8b408d8204fc7deec16d01c085ee199ff21a1f20b6346ce816cfe
\ No newline at end of file
+6b3d25b7982623ab4b25161aff9ab44778e136069043ab425543597c42c98ae5
\ No newline at end of file
index 8dac9ece522c4ea4f4995392995a1696656657a1..e3ca9a82a252a563fe55a534cdd1d5038ec75872 100644 (file)
@@ -505,7 +505,8 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
       return i;
     }
     case CC_KYWD0: {
-      for(i=1; aiClass[z[i]]<=CC_KYWD; i++){}
+      if( aiClass[z[1]]>CC_KYWD ){ i = 1;  break; }
+      for(i=2; aiClass[z[i]]<=CC_KYWD; i++){}
       if( IdChar(z[i]) ){
         /* This token started out using characters that can appear in keywords,
         ** but z[i] is a character not allowed within keywords, so this must
index 44e1d9c27cb3c63b3e6160a50cbcc66bb6896ab0..5386a36c4077b5f164c08899e320133ada8ce7b5 100644 (file)
@@ -665,39 +665,38 @@ int main(int argc, char **argv){
   printf("static int keywordCode(const char *z, int n, int *pType){\n");
   printf("  int i, j;\n");
   printf("  const char *zKW;\n");
-  printf("  if( n>=2 ){\n");
-  printf("    i = ((charMap(z[0])*%d) %c", HASH_C0, HASH_CC);
+  printf("  assert( n>=2 );\n");
+  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]; i>0; i=aKWNext[i]){\n");
-  printf("      if( aKWLen[i]!=n ) continue;\n");
-  printf("      zKW = &zKWText[aKWOffset[i]];\n");
+  printf("  for(i=(int)aKWHash[i]; i>0; i=aKWNext[i]){\n");
+  printf("    if( aKWLen[i]!=n ) continue;\n");
+  printf("    zKW = &zKWText[aKWOffset[i]];\n");
   printf("#ifdef SQLITE_ASCII\n");
-  printf("      if( (z[0]&~0x20)!=zKW[0] ) continue;\n");
-  printf("      if( (z[1]&~0x20)!=zKW[1] ) continue;\n");
-  printf("      j = 2;\n");
-  printf("      while( j<n && (z[j]&~0x20)==zKW[j] ){ j++; }\n");
+  printf("    if( (z[0]&~0x20)!=zKW[0] ) continue;\n");
+  printf("    if( (z[1]&~0x20)!=zKW[1] ) continue;\n");
+  printf("    j = 2;\n");
+  printf("    while( j<n && (z[j]&~0x20)==zKW[j] ){ j++; }\n");
   printf("#endif\n");
   printf("#ifdef SQLITE_EBCDIC\n");
-  printf("      if( toupper(z[0])!=zKW[0] ) continue;\n");
-  printf("      if( toupper(z[1])!=zKW[1] ) continue;\n");
-  printf("      j = 2;\n");
-  printf("      while( j<n && toupper(z[j])==zKW[j] ){ j++; }\n");
+  printf("    if( toupper(z[0])!=zKW[0] ) continue;\n");
+  printf("    if( toupper(z[1])!=zKW[1] ) continue;\n");
+  printf("    j = 2;\n");
+  printf("    while( j<n && toupper(z[j])==zKW[j] ){ j++; }\n");
   printf("#endif\n");
-  printf("      if( j<n ) continue;\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+1, aKeywordTable[i].zOrigName);
   }
-  printf("      *pType = aKWCode[i];\n");
-  printf("      break;\n");
-  printf("    }\n");
+  printf("    *pType = aKWCode[i];\n");
+  printf("    break;\n");
   printf("  }\n");
   printf("  return n;\n");
   printf("}\n");
   printf("int sqlite3KeywordCode(const unsigned char *z, int n){\n");
   printf("  int id = TK_ID;\n");
-  printf("  keywordCode((char*)z, n, &id);\n");
+  printf("  if( n>=2 ) keywordCode((char*)z, n, &id);\n");
   printf("  return id;\n");
   printf("}\n");
   printf("#define SQLITE_N_KEYWORD %d\n", nKeyword);