Skip to content

Commit

Permalink
Save a few bytes and a few cycles by setting Vdbe.expmask to zero for
Browse files Browse the repository at this point in the history
statements prepared using legacy interface sqlite3_prepare().
  • Loading branch information
danielk-1977 committed Feb 23, 2017
1 parent 6c33c03 commit 835115e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/vdbeapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
sqlite3VdbeMemRelease(&p->aVar[i]);
p->aVar[i].flags = MEM_Null;
}
if( p->isPrepareV2 && p->expmask ){
assert( p->isPrepareV2 || p->expmask==0 );
if( p->expmask ){
p->expired = 1;
}
sqlite3_mutex_leave(mutex);
Expand Down Expand Up @@ -1258,9 +1259,8 @@ static int vdbeUnbind(Vdbe *p, int i){
** as if there had been a schema change, on the first sqlite3_step() call
** following any change to the bindings of that parameter.
*/
if( p->isPrepareV2 &&
((i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff)
){
assert( p->isPrepareV2 || p->expmask==0 );
if( p->expmask & ((u32)1 << (i&0x001F)) && (i<32 || p->expmask==0xffffffff) ){
p->expired = 1;
}
return SQLITE_OK;
Expand Down Expand Up @@ -1523,10 +1523,12 @@ int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
if( pFrom->nVar!=pTo->nVar ){
return SQLITE_ERROR;
}
if( pTo->isPrepareV2 && pTo->expmask ){
assert( pTo->isPrepareV2 || pTo->expmask==0 );
if( pTo->expmask ){
pTo->expired = 1;
}
if( pFrom->isPrepareV2 && pFrom->expmask ){
assert( pFrom->isPrepareV2 || pFrom->expmask==0 );
if( pFrom->expmask ){
pFrom->expired = 1;
}
return sqlite3TransferBindings(pFromStmt, pToStmt);
Expand Down
1 change: 1 addition & 0 deletions src/vdbeaux.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void sqlite3VdbeError(Vdbe *p, const char *zFormat, ...){
void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
assert( isPrepareV2==1 || isPrepareV2==0 );
if( p==0 ) return;
if( !isPrepareV2 ) p->expmask = 0;
#if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
if( !isPrepareV2 ) return;
#endif
Expand Down

0 comments on commit 835115e

Please sign in to comment.