/ Check-in [5c499da8]
Login

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

Overview
Comment:Change the sqlite3VdbeMemGrow() routine so that it no longer guarantees a minimum size of 32 bytes. That minimum is no longer required, and without the extra check for the minimum size, the routine runs faster.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:5c499da8a4d0babc56883aa362ae124772fd9214a51169a88a5dee523d051658
User & Date: drh 2019-02-08 15:59:20
Context
2019-02-08
17:28
Further simplifications to sqlite3VdbeMemSetStr(). check-in: 1d212957 user: drh tags: trunk
15:59
Change the sqlite3VdbeMemGrow() routine so that it no longer guarantees a minimum size of 32 bytes. That minimum is no longer required, and without the extra check for the minimum size, the routine runs faster. check-in: 5c499da8 user: drh tags: trunk
14:55
Give the sqlite3 object a pointer to the current Parse so that if an OOM occurs, it can automatically set the Parse.rc value to SQLITE_NOMEM. This avoids a frequent extra test of db.mallocFailed in the innermost parser loop. check-in: 5c663804 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

   174    174     assert(rc==SQLITE_OK    || pMem->enc!=desiredEnc);
   175    175     assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);
   176    176     return rc;
   177    177   #endif
   178    178   }
   179    179   
   180    180   /*
   181         -** Make sure pMem->z points to a writable allocation of at least 
   182         -** min(n,32) bytes.
          181  +** Make sure pMem->z points to a writable allocation of at least n bytes.
   183    182   **
   184    183   ** If the bPreserve argument is true, then copy of the content of
   185    184   ** pMem->z into the new allocation.  pMem must be either a string or
   186    185   ** blob if bPreserve is true.  If bPreserve is false, any prior content
   187    186   ** in pMem->z is discarded.
   188    187   */
   189    188   SQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){
................................................................................
   194    193     /* If the bPreserve flag is set to true, then the memory cell must already
   195    194     ** contain a valid string or blob value.  */
   196    195     assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
   197    196     testcase( bPreserve && pMem->z==0 );
   198    197   
   199    198     assert( pMem->szMalloc==0
   200    199          || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
   201         -  if( n<32 ) n = 32;
   202    200     if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
   203    201       pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
   204    202       bPreserve = 0;
   205    203     }else{
   206    204       if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
   207    205       pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
   208    206     }