From: drh Date: Thu, 2 Feb 2012 01:58:08 +0000 (+0000) Subject: Remove the nAlloc field from the ExprList object. X-Git-Tag: version-3.7.11~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d872bb180c08e87caae457e7be13131e1b5616fa;p=thirdparty%2Fsqlite.git Remove the nAlloc field from the ExprList object. FossilOrigin-Name: 5963de303a9106b446a9423aa838bfdf6bc1e7f3 --- diff --git a/manifest b/manifest index afc55c0f8a..55ab179622 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Very\ssmall\sperformance\senhancement\sand\sreduction\sin\ssize\sof\sthe\ssqlite3_stmt\nobject. -D 2012-02-01T19:03:38.503 +C Remove\sthe\snAlloc\sfield\sfrom\sthe\sExprList\sobject. +D 2012-02-02T01:58:08.811 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -134,7 +134,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c a9c26822515f81ec21588cbb482ca6724be02e33 F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c 51d32f0a9c880663e54ce309f52e40c325d5e112 -F src/expr.c 537591e95eac74af783e4eb033954fb218cf398e +F src/expr.c d644aac3409c67c9a9bcf9d5098641b18b47d925 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 657212460bf5cfd3ae607d12ea62092844c227b5 F src/func.c 6261ce00aad9c63cd5b4219249b05683979060e9 @@ -184,7 +184,7 @@ F src/select.c 1ad267692ab09afe05092eddcb5aba96b796afe1 F src/shell.c 60d147c2411dd2d79a5151cfb9a068de87c7babe F src/sqlite.h.in 371c30e4be94b9b0ea6400ed66663fcf8e891eb4 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h f388afe0c10584da55dd8978657fc218672bcb80 +F src/sqliteInt.h f6b1d14dbabf8bc86f7d48da64c1ed881c747eb8 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 4568e72dfd36b6a5911f93457364deb072e0b03a F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -988,7 +988,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 0d78ebb8e41ba08b446b44694d9433e1e90e0a7e -R 64a40856f24d267fa939185d6a829659 +P a38d57a4e5d79a0baefdf776e0e2d61423681a4f +R 77e04796737c9c6ab169ded8e9e97e0e U drh -Z 4b158c38a343d7d874c1c1063287a2d3 +Z 60619f3cb0418eda9860a313b8f07415 diff --git a/manifest.uuid b/manifest.uuid index 4b05d4f799..2ff05264a2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a38d57a4e5d79a0baefdf776e0e2d61423681a4f \ No newline at end of file +5963de303a9106b446a9423aa838bfdf6bc1e7f3 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 22643ff331..5034d40aeb 100644 --- a/src/expr.c +++ b/src/expr.c @@ -856,8 +856,9 @@ ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){ pNew = sqlite3DbMallocRaw(db, sizeof(*pNew) ); if( pNew==0 ) return 0; pNew->iECursor = 0; - pNew->nExpr = pNew->nAlloc = p->nExpr; - pNew->a = pItem = sqlite3DbMallocRaw(db, p->nExpr*sizeof(p->a[0]) ); + pNew->nExpr = i = p->nExpr; + if( (flags & EXPRDUP_REDUCE)==0 ) for(i=1; inExpr; i+=i){} + pNew->a = pItem = sqlite3DbMallocRaw(db, i*sizeof(p->a[0]) ); if( pItem==0 ){ sqlite3DbFree(db, pNew); return 0; @@ -992,17 +993,16 @@ ExprList *sqlite3ExprListAppend( if( pList==0 ){ goto no_mem; } - assert( pList->nAlloc==0 ); - } - if( pList->nAlloc<=pList->nExpr ){ + pList->a = sqlite3DbMallocRaw(db, sizeof(pList->a[0])); + if( pList->a==0 ) goto no_mem; + }else if( (pList->nExpr & (pList->nExpr-1))==0 ){ struct ExprList_item *a; - int n = pList->nAlloc*2 + 4; - a = sqlite3DbRealloc(db, pList->a, n*sizeof(pList->a[0])); + assert( pList->nExpr>0 ); + a = sqlite3DbRealloc(db, pList->a, pList->nExpr*2*sizeof(pList->a[0])); if( a==0 ){ goto no_mem; } pList->a = a; - pList->nAlloc = sqlite3DbMallocSize(db, a)/sizeof(a[0]); } assert( pList->a!=0 ); if( 1 ){ @@ -1093,8 +1093,7 @@ void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){ int i; struct ExprList_item *pItem; if( pList==0 ) return; - assert( pList->a!=0 || (pList->nExpr==0 && pList->nAlloc==0) ); - assert( pList->nExpr<=pList->nAlloc ); + assert( pList->a!=0 || pList->nExpr==0 ); for(pItem=pList->a, i=0; inExpr; i++, pItem++){ sqlite3ExprDelete(db, pItem->pExpr); sqlite3DbFree(db, pItem->zName); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 1d625563ab..2d95feff20 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1775,9 +1775,8 @@ struct Expr { */ struct ExprList { int nExpr; /* Number of expressions on the list */ - int nAlloc; /* Number of entries allocated below */ int iECursor; /* VDBE Cursor associated with this ExprList */ - struct ExprList_item { + struct ExprList_item { /* For each expression in the list */ Expr *pExpr; /* The list of expressions */ char *zName; /* Token associated with this expression */ char *zSpan; /* Original text of the expression */ @@ -1785,7 +1784,7 @@ struct ExprList { u8 done; /* A flag to indicate when processing is finished */ u16 iOrderByCol; /* For ORDER BY, column number in result set */ u16 iAlias; /* Index into Parse.aAlias[] for zName */ - } *a; /* One entry for each expression */ + } *a; /* Alloc a power of two greater or equal to nExpr */ }; /*