SQLite

Check-in [f94cacc393]
Login

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

Overview
Comment:Performance enhancement in sqlite3VdbeMemNulTerminate().
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f94cacc393e895522b92c9717c53357afc918d60
User & Date: drh 2014-08-27 00:50:11.231
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: 1624916c6e user: drh tags: trunk)
00:50
Performance enhancement in sqlite3VdbeMemNulTerminate(). (check-in: f94cacc393 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: f1f94a971e user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/vdbemem.c.
196
197
198
199
200
201
202
203
204

205

206
207

208
209
210
211
212
213
214
215
216
217
218
219














220
221
222
223
224
225
226
196
197
198
199
200
201
202

203
204

205
206

207




208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236







-

+
-
+

-
+
-
-
-
-








+
+
+
+
+
+
+
+
+
+
+
+
+
+







    pMem->n += pMem->u.nZero;
    pMem->flags &= ~(MEM_Zero|MEM_Term);
  }
  return SQLITE_OK;
}
#endif


/*
** It is already known that pMem contains an unterminated string.
** Make sure the given Mem is \u0000 terminated.
** Add the zero terminator.
*/
int sqlite3VdbeMemNulTerminate(Mem *pMem){
static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){
  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
  if( (pMem->flags & MEM_Term)!=0 || (pMem->flags & MEM_Str)==0 ){
    return SQLITE_OK;   /* Nothing to do */
  }
  if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){
    return SQLITE_NOMEM;
  }
  pMem->z[pMem->n] = 0;
  pMem->z[pMem->n+1] = 0;
  pMem->flags |= MEM_Term;
  return SQLITE_OK;
}

/*
** Make sure the given Mem is \u0000 terminated.
*/
int sqlite3VdbeMemNulTerminate(Mem *pMem){
  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
  testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );
  testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );
  if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){
    return SQLITE_OK;   /* Nothing to do */
  }else{
    return vdbeMemAddTerminator(pMem);
  }
}

/*
** Add MEM_Str to the set of representations for the given Mem.  Numbers
** are converted using sqlite3_snprintf().  Converting a BLOB to a string
** is a no-op.
**
** Existing representations MEM_Int and MEM_Real are invalidated if