/ Check-in [ba6663be]
Login

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

Overview
Comment:Performance optimization in the yy_find_shift_action() routine of the Lemon-generated parser.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ba6663beefcc8060e6f3be6ab37c13fdbb08b7de
User & Date: drh 2016-08-10 01:43:30
Context
2016-08-10
11:50
Fix pcache1TruncateUnsafe() run faster for the case where iLimit is very close to iMaxKey. check-in: b07a26df user: drh tags: trunk
01:43
Performance optimization in the yy_find_shift_action() routine of the Lemon-generated parser. check-in: ba6663be user: drh tags: trunk
2016-08-09
21:01
Fix harmless compiler warning. check-in: 9a5a4f6e user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/lempar.c.

   446    446     int i;
   447    447     int stateno = pParser->yytos->stateno;
   448    448    
   449    449     if( stateno>=YY_MIN_REDUCE ) return stateno;
   450    450     assert( stateno <= YY_SHIFT_COUNT );
   451    451     do{
   452    452       i = yy_shift_ofst[stateno];
   453         -    if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno];
   454    453       assert( iLookAhead!=YYNOCODE );
   455    454       i += iLookAhead;
   456    455       if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
   457         -      if( iLookAhead>0 ){
   458    456   #ifdef YYFALLBACK
   459         -        YYCODETYPE iFallback;            /* Fallback token */
   460         -        if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
   461         -               && (iFallback = yyFallback[iLookAhead])!=0 ){
          457  +      YYCODETYPE iFallback;            /* Fallback token */
          458  +      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
          459  +             && (iFallback = yyFallback[iLookAhead])!=0 ){
   462    460   #ifndef NDEBUG
   463         -          if( yyTraceFILE ){
   464         -            fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
   465         -               yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
   466         -          }
   467         -#endif
   468         -          assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
   469         -          iLookAhead = iFallback;
   470         -          continue;
          461  +        if( yyTraceFILE ){
          462  +          fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n",
          463  +             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);
   471    464           }
          465  +#endif
          466  +        assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */
          467  +        iLookAhead = iFallback;
          468  +        continue;
          469  +      }
   472    470   #endif
   473    471   #ifdef YYWILDCARD
   474         -        {
   475         -          int j = i - iLookAhead + YYWILDCARD;
   476         -          if( 
          472  +      {
          473  +        int j = i - iLookAhead + YYWILDCARD;
          474  +        if( 
   477    475   #if YY_SHIFT_MIN+YYWILDCARD<0
   478         -            j>=0 &&
          476  +          j>=0 &&
   479    477   #endif
   480    478   #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
   481         -            j<YY_ACTTAB_COUNT &&
          479  +          j<YY_ACTTAB_COUNT &&
   482    480   #endif
   483         -            yy_lookahead[j]==YYWILDCARD
   484         -          ){
          481  +          yy_lookahead[j]==YYWILDCARD && iLookAhead>0
          482  +        ){
   485    483   #ifndef NDEBUG
   486         -            if( yyTraceFILE ){
   487         -              fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
   488         -                 yyTracePrompt, yyTokenName[iLookAhead],
   489         -                 yyTokenName[YYWILDCARD]);
   490         -            }
          484  +          if( yyTraceFILE ){
          485  +            fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n",
          486  +               yyTracePrompt, yyTokenName[iLookAhead],
          487  +               yyTokenName[YYWILDCARD]);
          488  +          }
   491    489   #endif /* NDEBUG */
   492         -            return yy_action[j];
   493         -          }
          490  +          return yy_action[j];
   494    491           }
   495         -#endif /* YYWILDCARD */
   496    492         }
          493  +#endif /* YYWILDCARD */
   497    494         return yy_default[stateno];
   498    495       }else{
   499    496         return yy_action[i];
   500    497       }
   501    498     }while(1);
   502    499   }
   503    500