diff options
author | drh <drh@noemail.net> | 2014-09-16 14:16:31 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2014-09-16 14:16:31 +0000 |
commit | 035e563bf62e749036825d85fdd885a4110810ce (patch) | |
tree | 4ec7e6a2f631a355f59707bd1c1a33c0990609f5 /src | |
parent | 7f4b19f170ff8010cd88c248aa9bf7b909d1dc75 (diff) | |
download | sqlite-035e563bf62e749036825d85fdd885a4110810ce.tar.gz sqlite-035e563bf62e749036825d85fdd885a4110810ce.zip |
Reorder the elements of the Mem object for a small size reduction and
performance improvement.
FossilOrigin-Name: 0be3019ed794c10de67dfd645ceea7d45815bc4b
Diffstat (limited to 'src')
-rw-r--r-- | src/func.c | 1 | ||||
-rw-r--r-- | src/vdbeInt.h | 13 | ||||
-rw-r--r-- | src/vdbeapi.c | 16 | ||||
-rw-r--r-- | src/vdbeaux.c | 5 | ||||
-rw-r--r-- | src/vdbemem.c | 2 |
5 files changed, 26 insertions, 11 deletions
diff --git a/src/func.c b/src/func.c index 0a8a9dda3..e1961118f 100644 --- a/src/func.c +++ b/src/func.c @@ -1492,6 +1492,7 @@ static void minmaxStep( sqlite3SkipAccumulatorLoad(context); } }else{ + pBest->db = sqlite3_context_db_handle(context); sqlite3VdbeMemCopy(pBest, pArg); } } diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 27b266986..5379d6b66 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -161,9 +161,6 @@ struct VdbeFrame { ** integer etc.) of the same value. */ struct Mem { - sqlite3 *db; /* The associated database connection */ - char *z; /* String or BLOB value */ - double r; /* Real value */ union { i64 i; /* Integer value used when MEM_Int is set in flags */ int nZero; /* Used when bit MEM_Zero is set in flags */ @@ -171,15 +168,19 @@ struct Mem { RowSet *pRowSet; /* Used only when flags==MEM_RowSet */ VdbeFrame *pFrame; /* Used when flags==MEM_Frame */ } u; - int n; /* Number of characters in string value, excluding '\0' */ u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */ + int n; /* Number of characters in string value, excluding '\0' */ + double r; /* Real value */ + char *z; /* String or BLOB value */ + char *zMalloc; /* Dynamic buffer allocated by sqlite3_malloc() */ + /* ShallowCopy only needs to copy the information above */ + sqlite3 *db; /* The associated database connection */ + void (*xDel)(void*);/* If not null, call this function to delete Mem.z */ #ifdef SQLITE_DEBUG Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */ void *pFiller; /* So that sizeof(Mem) is a multiple of 8 */ #endif - void (*xDel)(void *); /* If not null, call this function to delete Mem.z */ - char *zMalloc; /* Dynamic buffer allocated by sqlite3_malloc() */ }; /* One or more of the following flags are set to indicate the validOK diff --git a/src/vdbeapi.c b/src/vdbeapi.c index b64f33c8c..14d6b8412 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -803,11 +803,21 @@ static const Mem *columnNullValue(void){ #if defined(SQLITE_DEBUG) && defined(__GNUC__) __attribute__((aligned(8))) #endif - = {0, "", (double)0, {0}, 0, MEM_Null, 0, + = { + .flags = MEM_Null, + .enc = 0, + .n = 0, + .r = (double)0, + .u = {0}, + .z = 0, + .zMalloc = 0, + .db = 0, + .xDel = 0, #ifdef SQLITE_DEBUG - 0, 0, /* pScopyFrom, pFiller */ + .pScopyFrom = 0, + .pFiller = 0, #endif - 0, 0 }; + }; return &nullMem; } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 3360d919b..65792b485 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3303,8 +3303,9 @@ static int vdbeCompareMemString( int n1, n2; Mem c1; Mem c2; - memset(&c1, 0, sizeof(c1)); - memset(&c2, 0, sizeof(c2)); + c1.db = c2.db = pMem1->db; + c1.flags = c2.flags = 0; + c1.zMalloc = c2.zMalloc = 0; sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem); sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem); v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc); diff --git a/src/vdbemem.c b/src/vdbemem.c index ea4def3f8..7785bc0de 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -730,6 +730,7 @@ void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){ */ void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){ assert( (pFrom->flags & MEM_RowSet)==0 ); + assert( pTo->db==pFrom->db ); VdbeMemReleaseExtern(pTo); memcpy(pTo, pFrom, MEMCELLSIZE); pTo->xDel = 0; @@ -747,6 +748,7 @@ void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){ int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){ int rc = SQLITE_OK; + assert( pTo->db==pFrom->db ); assert( (pFrom->flags & MEM_RowSet)==0 ); VdbeMemReleaseExtern(pTo); memcpy(pTo, pFrom, MEMCELLSIZE); |