/ Check-in [ff406b97]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Faster keywordCode() implementation by taking advantage of the fact that the input is always pure ASCII alphabetic and underscore and that the keyword table is always upper-case.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tokenizer-char-class
Files: files | file ages | folders
SHA1: ff406b9701ebe3a01834837f380641c6f0c495bc
User & Date: drh 2016-02-08 03:23:46
Context
2016-02-08
19:15
Add code to get the tokenizer character-class logic working for EBCDIC. Closed-Leaf check-in: 04f7da77 user: drh tags: tokenizer-char-class
03:23
Faster keywordCode() implementation by taking advantage of the fact that the input is always pure ASCII alphabetic and underscore and that the keyword table is always upper-case. check-in: ff406b97 user: drh tags: tokenizer-char-class
02:30
Demonstrate a much faster sqlite3GetToken() routine by using a lookup table to map initial token characters into a character class. This check-in does not work for EBCDIC. More optimization needed. check-in: 9115baa1 user: drh tags: tokenizer-char-class
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/mkkeywordhash.c.

   561    561       if( j>=5 ){
   562    562         printf("\n");
   563    563         j = 0;
   564    564       }
   565    565     }
   566    566     printf("%s  };\n", j==0 ? "" : "\n");
   567    567   
   568         -  printf("  int h, i;\n");
          568  +  printf("  int h, i, j;\n");
          569  +  printf("  const char *zKW;\n");
   569    570     printf("  if( n>=2 ){\n");
   570    571     printf("    h = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) %% %d;\n",
   571    572             bestSize);
   572    573     printf("    for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){\n");
   573         -  printf("      if( aLen[i]==n &&"
   574         -                     " sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){\n");
          574  +  printf("      if( aLen[i]!=n ) continue;\n");
          575  +  printf("      j = 0;\n");
          576  +  printf("      zKW = &zText[aOffset[i]];\n");
          577  +  printf("      while( j<n && (z[j]&~0x20)==zKW[j] ){ j++; }\n");
          578  +  printf("      if( j<n ) continue;\n");
   575    579     for(i=0; i<nKeyword; i++){
   576         -    printf("        testcase( i==%d ); /* %s */\n",
          580  +    printf("      testcase( i==%d ); /* %s */\n",
   577    581              i, aKeywordTable[i].zOrigName);
   578    582     }
   579         -  printf("        *pType = aCode[i];\n");
   580         -  printf("        break;\n");
   581         -  printf("      }\n");
          583  +  printf("      *pType = aCode[i];\n");
          584  +  printf("      break;\n");
   582    585     printf("    }\n");
   583    586     printf("  }\n");
   584    587     printf("  return n;\n");
   585    588     printf("}\n");
   586    589     printf("int sqlite3KeywordCode(const unsigned char *z, int n){\n");
   587    590     printf("  int id = TK_ID;\n");
   588    591     printf("  keywordCode((char*)z, n, &id);\n");
   589    592     printf("  return id;\n");
   590    593     printf("}\n");
   591    594     printf("#define SQLITE_N_KEYWORD %d\n", nKeyword);
   592    595   
   593    596     return 0;
   594    597   }