1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Performance optimizations.

FossilOrigin-Name: f1d06c49ba0d814dc7ffb538aac3f4e6251fd8f0
This commit is contained in:
drh
2016-09-03 01:46:15 +00:00
parent 55a6f6dc72
commit 4910a76d45
5 changed files with 31 additions and 28 deletions

View File

@@ -1980,7 +1980,7 @@ case OP_Lt: /* same as TK_LT, jump, in1, in3 */
case OP_Le: /* same as TK_LE, jump, in1, in3 */
case OP_Gt: /* same as TK_GT, jump, in1, in3 */
case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
int res; /* Result of the comparison of pIn1 against pIn3 */
int res, res2; /* Result of the comparison of pIn1 against pIn3 */
char affinity; /* Affinity to use for comparison */
u16 flags1; /* Copy of initial value of pIn1->flags */
u16 flags3; /* Copy of initial value of pIn3->flags */
@@ -2003,18 +2003,18 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
&& (flags3&MEM_Null)!=0
&& (flags3&MEM_Cleared)==0
){
iCompare = 0; /* Operands are equal */
res = 0; /* Operands are equal */
}else{
iCompare = 1; /* Operands are not equal */
res = 1; /* Operands are not equal */
}
}else{
/* SQLITE_NULLEQ is clear and at least one operand is NULL,
** then the result is always NULL.
** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
*/
iCompare = 1; /* Operands are not equal */
if( pOp->p5 & SQLITE_STOREP2 ){
pOut = &aMem[pOp->p2];
iCompare = 1; /* Operands are not equal */
memAboutToChange(p, pOut);
MemSetTypeFlag(pOut, MEM_Null);
REGISTER_TRACE(pOp->p2, pOut);
@@ -2065,15 +2065,15 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
sqlite3VdbeMemExpandBlob(pIn3);
flags3 &= ~MEM_Zero;
}
iCompare = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
}
switch( pOp->opcode ){
case OP_Eq: res = iCompare==0; break;
case OP_Ne: res = iCompare!=0; break;
case OP_Lt: res = iCompare<0; break;
case OP_Le: res = iCompare<=0; break;
case OP_Gt: res = iCompare>0; break;
default: res = iCompare>=0; break;
case OP_Eq: res2 = res==0; break;
case OP_Ne: res2 = res; break;
case OP_Lt: res2 = res<0; break;
case OP_Le: res2 = res<=0; break;
case OP_Gt: res2 = res>0; break;
default: res2 = res>=0; break;
}
/* Undo any changes made by applyAffinity() to the input registers. */
@@ -2084,20 +2084,22 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
if( pOp->p5 & SQLITE_STOREP2 ){
pOut = &aMem[pOp->p2];
iCompare = res;
res2 = res2!=0; /* For this path res2 must be exactly 0 or 1 */
if( (pOp->p5 & SQLITE_KEEPNULL)!=0 && (pOut->flags & MEM_Null)!=0 ){
/* The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1
** and prevents OP_Ne from overwriting NULL with 0. */
assert( pOp->opcode==OP_Ne || pOp->opcode==OP_Eq );
assert( res==0 || res==1 );
if( (pOp->opcode==OP_Eq)==res ) break;
assert( res2==0 || res2==1 );
if( (pOp->opcode==OP_Eq)==res2 ) break;
}
memAboutToChange(p, pOut);
MemSetTypeFlag(pOut, MEM_Int);
pOut->u.i = res;
pOut->u.i = res2;
REGISTER_TRACE(pOp->p2, pOut);
}else{
VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
if( res ){
if( res2 ){
goto jump_to_p2;
}
}
@@ -2115,6 +2117,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */
assert( pOp>aOp );
assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt );
assert( pOp[-1].p5 & SQLITE_STOREP2 );
VdbeBranchTaken(iCompare!=0, 2);
if( iCompare!=0 ) goto jump_to_p2;
break;
@@ -6864,8 +6867,8 @@ case OP_Init: { /* jump */
}
#endif /* SQLITE_DEBUG */
#endif /* SQLITE_OMIT_TRACE */
if( pOp->p2 ) goto jump_to_p2;
break;
assert( pOp->p2>0 );
goto jump_to_p2;
}
#ifdef SQLITE_ENABLE_CURSOR_HINTS