/ Check-in [25d1d02b]
Login

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

Overview
Comment:Rearrange the code inside sqlite3RunParser() routine so that sqlite3Parser() is only called from a single place. This allows sqlite3Parser() to be in-lined, which results in a 0.25% overall performance gain.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 25d1d02b3ea126ade22b2a72649ae55509aa1777
User & Date: drh 2016-08-10 14:40:00
Context
2016-08-10
15:02
Tweaks to pcache1TruncateUnsafe() to make it slightly smaller and faster and easier to test. check-in: 059f4e2e user: drh tags: trunk
14:40
Rearrange the code inside sqlite3RunParser() routine so that sqlite3Parser() is only called from a single place. This allows sqlite3Parser() to be in-lined, which results in a 0.25% overall performance gain. check-in: 25d1d02b user: drh tags: trunk
13:34
Increment the version number to 3.15. check-in: 8c2701e7 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/tokenize.c.

   498    498       return SQLITE_NOMEM_BKPT;
   499    499     }
   500    500     assert( pParse->pNewTable==0 );
   501    501     assert( pParse->pNewTrigger==0 );
   502    502     assert( pParse->nVar==0 );
   503    503     assert( pParse->nzVar==0 );
   504    504     assert( pParse->azVar==0 );
   505         -  while( zSql[i]!=0 ){
          505  +  while( 1 ){
   506    506       assert( i>=0 );
   507         -    pParse->sLastToken.z = &zSql[i];
   508         -    pParse->sLastToken.n = sqlite3GetToken((unsigned char*)&zSql[i],&tokenType);
   509         -    i += pParse->sLastToken.n;
   510         -    if( i>mxSqlLen ){
   511         -      pParse->rc = SQLITE_TOOBIG;
   512         -      break;
          507  +    if( zSql[i]!=0 ){
          508  +      pParse->sLastToken.z = &zSql[i];
          509  +      pParse->sLastToken.n = sqlite3GetToken((u8*)&zSql[i],&tokenType);
          510  +      i += pParse->sLastToken.n;
          511  +      if( i>mxSqlLen ){
          512  +        pParse->rc = SQLITE_TOOBIG;
          513  +        break;
          514  +      }
          515  +    }else{
          516  +      /* Upon reaching the end of input, call the parser two more times
          517  +      ** with tokens TK_SEMI and 0, in that order. */
          518  +      if( lastTokenParsed==TK_SEMI ){
          519  +        tokenType = 0;
          520  +      }else if( lastTokenParsed==0 ){
          521  +        break;
          522  +      }else{
          523  +        tokenType = TK_SEMI;
          524  +      }
   513    525       }
   514    526       if( tokenType>=TK_SPACE ){
   515    527         assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );
   516    528         if( db->u1.isInterrupted ){
   517    529           pParse->rc = SQLITE_INTERRUPT;
   518    530           break;
   519    531         }
................................................................................
   526    538         sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse);
   527    539         lastTokenParsed = tokenType;
   528    540         if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;
   529    541       }
   530    542     }
   531    543     assert( nErr==0 );
   532    544     pParse->zTail = &zSql[i];
   533         -  if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){
   534         -    assert( zSql[i]==0 );
   535         -    if( lastTokenParsed!=TK_SEMI ){
   536         -      sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse);
   537         -    }
   538         -    if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){
   539         -      sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
   540         -    }
   541         -  }
   542    545   #ifdef YYTRACKMAXSTACKDEPTH
   543    546     sqlite3_mutex_enter(sqlite3MallocMutex());
   544    547     sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK,
   545    548         sqlite3ParserStackPeak(pEngine)
   546    549     );
   547    550     sqlite3_mutex_leave(sqlite3MallocMutex());
   548    551   #endif /* YYDEBUG */