Reorder the elements of the Mem object for a small size reduction and

performance improvement.

FossilOrigin-Name: 0be3019ed794c10de67dfd645ceea7d45815bc4b
This commit is contained in:
drh
2014-09-16 14:16:31 +00:00
parent 7f4b19f170
commit 035e563bf6
7 changed files with 37 additions and 22 deletions
+1
View File
@@ -1492,6 +1492,7 @@ static void minmaxStep(
sqlite3SkipAccumulatorLoad(context);
}
}else{
pBest->db = sqlite3_context_db_handle(context);
sqlite3VdbeMemCopy(pBest, pArg);
}
}
+7 -6
View File
@@ -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
+13 -3
View File
@@ -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;
}
+3 -2
View File
@@ -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);
+2
View File
@@ -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);