diff options
author | drh <> | 2024-06-06 01:21:57 +0000 |
---|---|---|
committer | drh <> | 2024-06-06 01:21:57 +0000 |
commit | fd6beda14be03cb0236a853128fa1cae8373eea3 (patch) | |
tree | ed3c1becc1be11283ff0992c203a113980a70c17 /src | |
parent | 48f5e527283d1f8a3811bd157a15d1ae34ad03d7 (diff) | |
download | sqlite-fd6beda14be03cb0236a853128fa1cae8373eea3.tar.gz sqlite-fd6beda14be03cb0236a853128fa1cae8373eea3.zip |
Adjust the parser so that the value of TK_ISNOT is similar to the value of
TK_IS. This helps the compiler generate faster switch() statements on the
Expr.op fields when there are cases for TK_ISNOT and other common operators.
FossilOrigin-Name: 34f05c3d89b2dd15e4b0d1ba292df7de3dfc54b505c0ba145cc3db52cf020845
Diffstat (limited to 'src')
-rw-r--r-- | src/parse.y | 6 | ||||
-rw-r--r-- | src/whereexpr.c | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/parse.y b/src/parse.y index 90277f9c0..de8282e81 100644 --- a/src/parse.y +++ b/src/parse.y @@ -236,11 +236,13 @@ columnname(A) ::= nm(A) typetoken(Y). {sqlite3AddColumn(pParse,A,Y);} // improve performance and reduce the executable size. The goal here is // to get the "jump" operations in ISNULL through ESCAPE to have numeric // values that are early enough so that all jump operations are clustered -// at the beginning. +// at the beginning. Also, operators like NE and EQ need to be adjacent, +// and all of the comparison operators need to be clustered together. +// Various assert() statements throughout the code enforce these restrictions. // %token ABORT ACTION AFTER ANALYZE ASC ATTACH BEFORE BEGIN BY CASCADE CAST. %token CONFLICT DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL. -%token OR AND NOT IS MATCH LIKE_KW BETWEEN IN ISNULL NOTNULL NE EQ. +%token OR AND NOT IS ISNOT MATCH LIKE_KW BETWEEN IN ISNULL NOTNULL NE EQ. %token GT LE LT GE ESCAPE. // The following directive causes tokens ABORT, AFTER, ASC, etc. to diff --git a/src/whereexpr.c b/src/whereexpr.c index 41d6ac9f0..ae1c838c0 100644 --- a/src/whereexpr.c +++ b/src/whereexpr.c @@ -435,6 +435,13 @@ static int isAuxiliaryVtabOperator( } } } + }else if( pExpr->op>=TK_EQ ){ + /* Comparison operators are a common case. Save a few comparisons for + ** that common case by terminating early. */ + assert( TK_NE < TK_EQ ); + assert( TK_ISNOT < TK_EQ ); + assert( TK_NOTNULL < TK_EQ ); + return 0; }else if( pExpr->op==TK_NE || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL ){ int res = 0; Expr *pLeft = pExpr->pLeft; |