/ Check-in [f94cacc3]
Login

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

Overview
Comment:Performance enhancement in sqlite3VdbeMemNulTerminate().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f94cacc393e895522b92c9717c53357afc918d60
User & Date: drh 2014-08-27 00:50:11
Context
2014-08-27
03:28
Factor out the exception paths from sqlite3ValueToText() into a separate function so that the main routine is much faster for the common case of no required type or encoding conversions. check-in: 1624916c user: drh tags: trunk
00:50
Performance enhancement in sqlite3VdbeMemNulTerminate(). check-in: f94cacc3 user: drh tags: trunk
2014-08-26
15:06
Change the page cache so that a new sqlite3_pcache object is allocated as soon as the page cache is opened, not delayed until the first fetch request. This give a noticable performance boost. The interface between pager and the page cache has changed slightly, which might break ZIPVFS. check-in: f1f94a97 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

   196    196       pMem->n += pMem->u.nZero;
   197    197       pMem->flags &= ~(MEM_Zero|MEM_Term);
   198    198     }
   199    199     return SQLITE_OK;
   200    200   }
   201    201   #endif
   202    202   
   203         -
   204    203   /*
   205         -** Make sure the given Mem is \u0000 terminated.
          204  +** It is already known that pMem contains an unterminated string.
          205  +** Add the zero terminator.
   206    206   */
   207         -int sqlite3VdbeMemNulTerminate(Mem *pMem){
   208         -  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
   209         -  if( (pMem->flags & MEM_Term)!=0 || (pMem->flags & MEM_Str)==0 ){
   210         -    return SQLITE_OK;   /* Nothing to do */
   211         -  }
          207  +static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){
   212    208     if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){
   213    209       return SQLITE_NOMEM;
   214    210     }
   215    211     pMem->z[pMem->n] = 0;
   216    212     pMem->z[pMem->n+1] = 0;
   217    213     pMem->flags |= MEM_Term;
   218    214     return SQLITE_OK;
   219    215   }
          216  +
          217  +/*
          218  +** Make sure the given Mem is \u0000 terminated.
          219  +*/
          220  +int sqlite3VdbeMemNulTerminate(Mem *pMem){
          221  +  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
          222  +  testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );
          223  +  testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );
          224  +  if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){
          225  +    return SQLITE_OK;   /* Nothing to do */
          226  +  }else{
          227  +    return vdbeMemAddTerminator(pMem);
          228  +  }
          229  +}
   220    230   
   221    231   /*
   222    232   ** Add MEM_Str to the set of representations for the given Mem.  Numbers
   223    233   ** are converted using sqlite3_snprintf().  Converting a BLOB to a string
   224    234   ** is a no-op.
   225    235   **
   226    236   ** Existing representations MEM_Int and MEM_Real are invalidated if