/ Check-in [9748c48a]
Login

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

Overview
Comment:Size reduction and performance improvement in the stack-popping logic of the Lemon-generated parser.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9748c48a4fbd5c06208bbf80e7bfcb159ec026d9
User & Date: drh 2015-11-09 14:11:37
Context
2015-11-09
15:06
Avoid recursion in the yy_find_shift_action() routine of the Lemon-generated parser, so that routine can be inlined, for a size reduction and performance increase. check-in: 0557a179 user: drh tags: trunk
14:11
Size reduction and performance improvement in the stack-popping logic of the Lemon-generated parser. check-in: 9748c48a user: drh tags: trunk
12:47
Fix incorrect WHERE clause in sqldiff, as reported on the mailing list by Youcef Hilem. check-in: e0ed4c3e user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/lempar.c.

   328    328   }
   329    329   
   330    330   /*
   331    331   ** Pop the parser's stack once.
   332    332   **
   333    333   ** If there is a destructor routine associated with the token which
   334    334   ** is popped from the stack, then call it.
   335         -**
   336         -** Return the major token number for the symbol popped.
   337    335   */
   338         -static int yy_pop_parser_stack(yyParser *pParser){
   339         -  YYCODETYPE yymajor;
   340         -  yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
   341         -
   342         -  /* There is no mechanism by which the parser stack can be popped below
   343         -  ** empty in SQLite.  */
          336  +static void yy_pop_parser_stack(yyParser *pParser){
          337  +  yyStackEntry *yytos;
   344    338     assert( pParser->yyidx>=0 );
          339  +  yytos = &pParser->yystack[pParser->yyidx--];
   345    340   #ifndef NDEBUG
   346         -  if( yyTraceFILE && pParser->yyidx>=0 ){
          341  +  if( yyTraceFILE ){
   347    342       fprintf(yyTraceFILE,"%sPopping %s\n",
   348    343         yyTracePrompt,
   349    344         yyTokenName[yytos->major]);
   350    345     }
   351    346   #endif
   352         -  yymajor = yytos->major;
   353         -  yy_destructor(pParser, yymajor, &yytos->minor);
   354         -  pParser->yyidx--;
   355         -  return yymajor;
          347  +  yy_destructor(pParser, yytos->major, &yytos->minor);
   356    348   }
   357    349   
   358    350   /* 
   359    351   ** Deallocate and destroy a parser.  Destructors are all called for
   360    352   ** all stack elements before shutting the parser down.
   361    353   **
   362    354   ** Inputs:

Changes to tool/lempar.c.

   322    322   }
   323    323   
   324    324   /*
   325    325   ** Pop the parser's stack once.
   326    326   **
   327    327   ** If there is a destructor routine associated with the token which
   328    328   ** is popped from the stack, then call it.
   329         -**
   330         -** Return the major token number for the symbol popped.
   331    329   */
   332         -static int yy_pop_parser_stack(yyParser *pParser){
   333         -  YYCODETYPE yymajor;
   334         -  yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
   335         -
   336         -  if( pParser->yyidx<0 ) return 0;
          330  +static void yy_pop_parser_stack(yyParser *pParser){
          331  +  yyStackEntry *yytos;
          332  +  assert( pParser->yyidx>=0 );
          333  +  yytos = &pParser->yystack[pParser->yyidx--];
   337    334   #ifndef NDEBUG
   338         -  if( yyTraceFILE && pParser->yyidx>=0 ){
          335  +  if( yyTraceFILE ){
   339    336       fprintf(yyTraceFILE,"%sPopping %s\n",
   340    337         yyTracePrompt,
   341    338         yyTokenName[yytos->major]);
   342    339     }
   343    340   #endif
   344         -  yymajor = yytos->major;
   345         -  yy_destructor(pParser, yymajor, &yytos->minor);
   346         -  pParser->yyidx--;
   347         -  return yymajor;
          341  +  yy_destructor(pParser, yytos->major, &yytos->minor);
   348    342   }
   349    343   
   350    344   /* 
   351    345   ** Deallocate and destroy a parser.  Destructors are all called for
   352    346   ** all stack elements before shutting the parser down.
   353    347   **
   354    348   ** Inputs: