/ Check-in [4b3f7eac]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Size and performance optimization on sqlite3VdbeMemGrow().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4b3f7eacb862fbb5b75cf50b72fb60dfbd0acb5818e9f83383a6a63c8bbeacdf
User & Date: drh 2017-09-20 18:47:51
Context
2017-09-21
00:49
Fix the rendering of the P4_INTARRAY argument to the OP_IntegrityCk opcode in the output of EXPLAIN. check-in: adc12c83 user: drh tags: trunk
2017-09-20
18:47
Size and performance optimization on sqlite3VdbeMemGrow(). check-in: 4b3f7eac user: drh tags: trunk
18:07
The BLOB returned by sqlite3VdbeMemFromBtree() does not need to be zero-terminated. check-in: e0af9a90 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

   151    151     ** contain a valid string or blob value.  */
   152    152     assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
   153    153     testcase( bPreserve && pMem->z==0 );
   154    154   
   155    155     assert( pMem->szMalloc==0
   156    156          || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
   157    157     if( n<32 ) n = 32;
   158         -  if( bPreserve && pMem->szMalloc>0 && pMem->z==pMem->zMalloc ){
          158  +  if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
   159    159       pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
   160    160       bPreserve = 0;
   161    161     }else{
   162    162       if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
   163    163       pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
   164    164     }
   165    165     if( pMem->zMalloc==0 ){
................................................................................
   167    167       pMem->z = 0;
   168    168       pMem->szMalloc = 0;
   169    169       return SQLITE_NOMEM_BKPT;
   170    170     }else{
   171    171       pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
   172    172     }
   173    173   
   174         -  if( bPreserve && pMem->z && ALWAYS(pMem->z!=pMem->zMalloc) ){
          174  +  if( bPreserve && pMem->z ){
          175  +    assert( pMem->z!=pMem->zMalloc );
   175    176       memcpy(pMem->zMalloc, pMem->z, pMem->n);
   176    177     }
   177    178     if( (pMem->flags&MEM_Dyn)!=0 ){
   178    179       assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );
   179    180       pMem->xDel((void *)(pMem->z));
   180    181     }
   181    182