]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
General code cleanup resulting in smaller footprint. (CVS 2595)
authordrh <drh@noemail.net>
Sun, 14 Aug 2005 20:47:16 +0000 (20:47 +0000)
committerdrh <drh@noemail.net>
Sun, 14 Aug 2005 20:47:16 +0000 (20:47 +0000)
FossilOrigin-Name: 98338abf9e8cfbf8efa81cff0e40ea37e34fd9b2

manifest
manifest.uuid
src/expr.c
src/select.c

index ae3c2007552a572829f6a5dee4b2aad3218fbcdb..98087f67c4cb39285348d738c136de42161b1997 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Split\sthe\ssqlite3_complete()\sAPI\sout\sinto\sa\sseparate\ssource\sfile\sso\sthat\nin\sstatic\slinks\swhere\sit\sis\snot\sused\sit\swill\snot\stake\sup\sspace\sin\sthe\nresulting\sbinary.\s(CVS\s2594)
-D 2005-08-14T17:53:21
+C General\scode\scleanup\sresulting\sin\ssmaller\sfootprint.\s(CVS\s2595)
+D 2005-08-14T20:47:16
 F Makefile.in b109ddb46a5550d0732dcd6caca01c123f6d5cdd
 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -40,7 +40,7 @@ F src/complete.c 4de937dfdd4c79a501772ab2035b26082f337a79
 F src/date.c 7444b0900a28da77e57e3337a636873cff0ae940
 F src/delete.c be1fc25c9e109cd8cbab42a43ee696263da7c04b
 F src/experimental.c 50c1e3b34f752f4ac10c36f287db095c2b61766d
-F src/expr.c cad7f9197587db4897192cf21a8629b3b102c682
+F src/expr.c 24eda6c0502250f3a4259be94d6962f87cd47d87
 F src/func.c 5b12db87f0bc7d978eaf87c7a348ada5d1934da4
 F src/hash.c 2b1b13f7400e179631c83a1be0c664608c8f021f
 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
@@ -63,7 +63,7 @@ F src/pragma.c 69413fbdc0c6aaa493a776ea52c1b3e6cf35dfb2
 F src/prepare.c fa0f6068d9b8ec6d5c419c65d4d8ff747d49c5c6
 F src/printf.c 772b15c3395fa60bdbf3aaa03d480ecde38bf192
 F src/random.c 90adff4e73a3b249eb4f1fc2a6ff9cf78c7233a4
-F src/select.c c611471052773b94af771693686bd5bcdbbb0dba
+F src/select.c f441648eb191dcf1e67ae61475ea3b40a0eeb787
 F src/shell.c 86c16f0d534aa51cc82cf9f66903d4eb681580e7
 F src/sqlite.h.in a3b75a6b2e66865fba4ec1b698d00c7d95fe27a2
 F src/sqliteInt.h 40370b51b902b4789ca6d4a016d00fa981803661
@@ -293,7 +293,7 @@ F www/tclsqlite.tcl 3df553505b6efcad08f91e9b975deb2e6c9bb955
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
-P 94efd7908880c7d99c08ebc9a3437cfbefc42f7e
-R aba4d0123b815fe8fae7c07e56c29e43
+P 62b87751dea56c565bcc2aca88a2edda7dfc2a57
+R 8a2d641a343930304c476f8e7d5941a6
 U drh
-Z a0b138cf78bbb402904383cc3a8c7ee1
+Z 4e9e4effacefcf4b222166a8ff8d216c
index 0345c5584a36117a970a1dce1576916d5ea7e068..1acea4d97fe6602d31b8efae4eb1ca5cb35233a0 100644 (file)
@@ -1 +1 @@
-62b87751dea56c565bcc2aca88a2edda7dfc2a57
\ No newline at end of file
+98338abf9e8cfbf8efa81cff0e40ea37e34fd9b2
\ No newline at end of file
index 4bab5ead2bf1909c883e1179810c6721202bda03..a7a8f33632b620d09ac50da47387579a7ccf2648 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains routines used for analyzing expressions and
 ** for generating VDBE code that evaluates expressions in SQLite.
 **
-** $Id: expr.c,v 1.216 2005/08/12 22:58:53 drh Exp $
+** $Id: expr.c,v 1.217 2005/08/14 20:47:16 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1789,11 +1789,9 @@ int sqlite3ExprCodeExprList(
 ){
   struct ExprList_item *pItem;
   int i, n;
-  Vdbe *v;
   if( pList==0 ) return 0;
-  v = sqlite3GetVdbe(pParse);
   n = pList->nExpr;
-  for(pItem=pList->a, i=0; i<n; i++, pItem++){
+  for(pItem=pList->a, i=n; i>0; i--, pItem++){
     sqlite3ExprCode(pParse, pItem->pExpr);
   }
   return n;
index dd094451d8dbef0c0d6257609e49245471561044..ba633d6e95b55a9af5b624c6669a6aeedf22a3d9 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
 **
-** $Id: select.c,v 1.253 2005/07/08 17:13:47 drh Exp $
+** $Id: select.c,v 1.254 2005/08/14 20:47:16 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -85,7 +85,7 @@ int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
   Token *apAll[3];
   Token *p;
   static const struct {
-    const char *zKeyword;
+    const char zKeyword[8];
     u8 nChar;
     u8 code;
   } keywords[] = {
@@ -155,6 +155,15 @@ static void setToken(Token *p, const char *z){
   p->dyn = 0;
 }
 
+/*
+** Create an expression node for an identifier with the name of zName
+*/
+static Expr *createIdExpr(const char *zName){
+  Token dummy;
+  setToken(&dummy, zName);
+  return sqlite3Expr(TK_ID, 0, 0, &dummy);
+}
+
 
 /*
 ** Add a term to the WHERE expression in *ppExpr that requires the
@@ -168,24 +177,20 @@ static void addWhereTerm(
   const char *zAlias2,     /* Alias for second table.  May be NULL */
   Expr **ppExpr            /* Add the equality term to this expression */
 ){
-  Token dummy;
   Expr *pE1a, *pE1b, *pE1c;
   Expr *pE2a, *pE2b, *pE2c;
   Expr *pE;
 
-  setToken(&dummy, zCol);
-  pE1a = sqlite3Expr(TK_ID, 0, 0, &dummy);
-  pE2a = sqlite3Expr(TK_ID, 0, 0, &dummy);
+  pE1a = createIdExpr(zCol);
+  pE2a = createIdExpr(zCol);
   if( zAlias1==0 ){
     zAlias1 = pTab1->zName;
   }
-  setToken(&dummy, zAlias1);
-  pE1b = sqlite3Expr(TK_ID, 0, 0, &dummy);
+  pE1b = createIdExpr(zAlias1);
   if( zAlias2==0 ){
     zAlias2 = pTab2->zName;
   }
-  setToken(&dummy, zAlias2);
-  pE2b = sqlite3Expr(TK_ID, 0, 0, &dummy);
+  pE2b = createIdExpr(zAlias2);
   pE1c = sqlite3Expr(TK_DOT, pE1b, pE1a, 0);
   pE2c = sqlite3Expr(TK_DOT, pE2b, pE2a, 0);
   pE = sqlite3Expr(TK_EQ, pE1c, pE2c, 0);
@@ -321,10 +326,7 @@ void sqlite3SelectDelete(Select *p){
 ** stack into the sorter.
 */
 static void pushOntoSorter(Parse *pParse, Vdbe *v, ExprList *pOrderBy){
-  int i;
-  for(i=0; i<pOrderBy->nExpr; i++){
-    sqlite3ExprCode(pParse, pOrderBy->a[i].pExpr);
-  }
+  sqlite3ExprCodeExprList(pParse, pOrderBy);
   sqlite3VdbeAddOp(v, OP_MakeRecord, pOrderBy->nExpr, 0);
   sqlite3VdbeAddOp(v, OP_SortInsert, 0, 0);
 }
@@ -402,9 +404,7 @@ static int selectInnerLoop(
     }
   }else{
     nColumn = pEList->nExpr;
-    for(i=0; i<pEList->nExpr; i++){
-      sqlite3ExprCode(pParse, pEList->a[i].pExpr);
-    }
+    sqlite3ExprCodeExprList(pParse, pEList);
   }
 
   /* If the DISTINCT keyword was present on the SELECT statement
@@ -412,14 +412,15 @@ static int selectInnerLoop(
   ** part of the result.
   */
   if( hasDistinct ){
+    int n = pEList->nExpr;
 #if NULL_ALWAYS_DISTINCT
     sqlite3VdbeAddOp(v, OP_IsNull, -pEList->nExpr, sqlite3VdbeCurrentAddr(v)+7);
 #endif
     /* Deliberately leave the affinity string off of the following
     ** OP_MakeRecord */
-    sqlite3VdbeAddOp(v, OP_MakeRecord, pEList->nExpr * -1, 0);
+    sqlite3VdbeAddOp(v, OP_MakeRecord, -n, 0);
     sqlite3VdbeAddOp(v, OP_Distinct, distinct, sqlite3VdbeCurrentAddr(v)+3);
-    sqlite3VdbeAddOp(v, OP_Pop, pEList->nExpr+1, 0);
+    sqlite3VdbeAddOp(v, OP_Pop, n+1, 0);
     sqlite3VdbeAddOp(v, OP_Goto, 0, iContinue);
     VdbeComment((v, "# skip indistinct records"));
     sqlite3VdbeAddOp(v, OP_IdxInsert, distinct, 0);
@@ -511,33 +512,25 @@ static int selectInnerLoop(
     }
 #endif /* #ifndef SQLITE_OMIT_SUBQUERY */
 
-    /* Send the data to the callback function.
+    /* Send the data to the callback function or to a subroutine.  In the
+    ** case of a subroutine, the subroutine itself is responsible for
+    ** popping the data from the stack.
     */
+    case SRT_Subroutine:
     case SRT_Callback:
     case SRT_Sorter: {
       if( pOrderBy ){
         sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
         pushOntoSorter(pParse, v, pOrderBy);
+      }else if( eDest==SRT_Subroutine ){
+        sqlite3VdbeAddOp(v, OP_Gosub, 0, iParm);
       }else{
-        assert( eDest==SRT_Callback );
+        assert( eDest!=SRT_Sorter );
         sqlite3VdbeAddOp(v, OP_Callback, nColumn, 0);
       }
       break;
     }
 
-    /* Invoke a subroutine to handle the results.  The subroutine itself
-    ** is responsible for popping the results off of the stack.
-    */
-    case SRT_Subroutine: {
-      if( pOrderBy ){
-        sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
-        pushOntoSorter(pParse, v, pOrderBy);
-      }else{
-        sqlite3VdbeAddOp(v, OP_Gosub, 0, iParm);
-      }
-      break;
-    }
-
 #if !defined(SQLITE_OMIT_TRIGGER)
     /* Discard the results.  This is used for SELECT statements inside
     ** the body of a TRIGGER.  The purpose of such selects is to call
@@ -2766,9 +2759,7 @@ int sqlite3Select(
     int lbl1 = 0;
     pParse->fillAgg = 1;
     if( pGroupBy ){
-      for(i=0; i<pGroupBy->nExpr; i++){
-        sqlite3ExprCode(pParse, pGroupBy->a[i].pExpr);
-      }
+      sqlite3ExprCodeExprList(pParse, pGroupBy);
       /* No affinity string is attached to the following OP_MakeRecord 
       ** because we do not need to do any coercion of datatypes. */
       sqlite3VdbeAddOp(v, OP_MakeRecord, pGroupBy->nExpr, 0);