diff options
author | drh <drh@noemail.net> | 2006-01-12 12:43:36 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2006-01-12 12:43:36 +0000 |
commit | 4b494d65a75a3f6cc8f8998bb34d54f060b3ab93 (patch) | |
tree | 1f06752ac6f58f8491ce6196821e905e797e5858 /src | |
parent | f06c59a3e576b397cf75294b7bfef70d44c30005 (diff) | |
download | sqlite-4b494d65a75a3f6cc8f8998bb34d54f060b3ab93.tar.gz sqlite-4b494d65a75a3f6cc8f8998bb34d54f060b3ab93.zip |
About a 2.5% speed improvement by reducing the number of sqlite3ThreadData
calls in the parser. (CVS 2924)
FossilOrigin-Name: 0caa1994770142d6ca15284a26bad3879b07b15a
Diffstat (limited to 'src')
-rw-r--r-- | src/prepare.c | 10 | ||||
-rw-r--r-- | src/sqliteInt.h | 3 | ||||
-rw-r--r-- | src/tokenize.c | 7 | ||||
-rw-r--r-- | src/vdbeaux.c | 2 |
4 files changed, 14 insertions, 8 deletions
diff --git a/src/prepare.c b/src/prepare.c index d8d151094..a1cc6a7a5 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -13,7 +13,7 @@ ** interface, and routines that contribute to loading the database schema ** from disk. ** -** $Id: prepare.c,v 1.20 2006/01/11 21:41:22 drh Exp $ +** $Id: prepare.c,v 1.21 2006/01/12 12:43:36 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -517,9 +517,11 @@ int sqlite3_prepare( memset(&sParse, 0, sizeof(sParse)); sParse.db = db; + sParse.pTsd = sqlite3ThreadData(); + sParse.pTsd->nRef++; sqlite3RunParser(&sParse, zSql, &zErrMsg); - if( sqlite3ThreadDataReadOnly()->mallocFailed ){ + if( sParse.pTsd->mallocFailed ){ sParse.rc = SQLITE_NOMEM; } if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK; @@ -569,12 +571,14 @@ int sqlite3_prepare( /* We must check for malloc failure last of all, in case malloc() failed ** inside of the sqlite3Error() call above or something. */ - if( sqlite3ThreadDataReadOnly()->mallocFailed ){ + if( sParse.pTsd->mallocFailed ){ rc = SQLITE_NOMEM; sqlite3Error(db, rc, 0); } + sParse.pTsd->nRef--; sqlite3MallocClearFailed(); + sqlite3ReleaseThreadData(); return rc; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c06fa00c0..5977c9830 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.464 2006/01/12 01:56:44 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.465 2006/01/12 12:43:36 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -1257,6 +1257,7 @@ struct Parse { int ckOffset; /* Stack offset to data used by CHECK constraints */ u32 writeMask; /* Start a write transaction on these databases */ u32 cookieMask; /* Bitmask of schema verified databases */ + ThreadData *pTsd; /* Thread specific data for this thread */ int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */ int cookieValue[MAX_ATTACHED+2]; /* Values of cookies to verify */ #ifndef SQLITE_OMIT_SHARED_CACHE diff --git a/src/tokenize.c b/src/tokenize.c index ec2efbe78..86e526a9e 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -15,7 +15,7 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.113 2006/01/11 21:41:22 drh Exp $ +** $Id: tokenize.c,v 1.114 2006/01/12 12:43:36 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -339,6 +339,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ int tokenType; int lastTokenParsed = -1; sqlite3 *db = pParse->db; + ThreadData *pTsd = pParse->pTsd; extern void *sqlite3ParserAlloc(void*(*)(int)); extern void sqlite3ParserFree(void*, void(*)(void*)); extern int sqlite3Parser(void*, int, Token, Parse*); @@ -358,7 +359,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ assert( pParse->nVarExprAlloc==0 ); assert( pParse->apVarExpr==0 ); pParse->zTail = pParse->zSql = zSql; - while( sqlite3ThreadDataReadOnly()->mallocFailed==0 && zSql[i]!=0 ){ + while( pTsd->mallocFailed==0 && zSql[i]!=0 ){ assert( i>=0 ); pParse->sLastToken.z = (u8*)&zSql[i]; assert( pParse->sLastToken.dyn==0 ); @@ -406,7 +407,7 @@ abort_parse: sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse); } sqlite3ParserFree(pEngine, sqlite3FreeX); - if( sqlite3ThreadDataReadOnly()->mallocFailed ){ + if( pTsd->mallocFailed ){ pParse->rc = SQLITE_NOMEM; } if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index ab8282eae..637bb1bf3 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -102,7 +102,7 @@ int sqlite3VdbeAddOp(Vdbe *p, int op, int p1, int p2){ p->nOp++; assert( p->magic==VDBE_MAGIC_INIT ); resizeOpArray(p, i+1); - if( sqlite3ThreadDataReadOnly()->mallocFailed ){ + if( p->aOp==0 || p->nOp<=i ){ return 0; } pOp = &p->aOp[i]; |