Fossil

Check-in [3ad620df]
Login

Check-in [3ad620df]

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

Overview
Comment:Further performance improvements to the internal printf() implementation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3ad620df0058144d39fd950d819f2dc10cab1185a04ce3965833ab6f5cc19af2
User & Date: drh 2020-11-21 14:34:43
Context
2020-11-21
19:46
More aggressive reuse of prepared statements for improved performance. ... (check-in: f044cf2a user: drh tags: trunk)
14:34
Further performance improvements to the internal printf() implementation. ... (check-in: 3ad620df user: drh tags: trunk)
14:10
Performance optimization in the internal printf() implementation. ... (check-in: 008fc929 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/printf.c.

172
173
174
175
176
177
178

179
180
181
182
183
184
185
  {  'G',  0, 1, etGENERIC,    14, 0 },
  {  'i', 10, 1, etRADIX,      0,  0 },
  {  'n',  0, 0, etSIZE,       0,  0 },
  {  '%',  0, 0, etPERCENT,    0,  0 },
  {  'p', 16, 0, etPOINTER,    0,  1 },
  {  '/',  0, 0, etPATH,       0,  0 },
  {  '$',  0, 0, etSHELLESC,   0,  0 },

};
#define etNINFO count(fmtinfo)

/*
** Verify that the fmtchr[] and fmtinfo[] arrays are in agreement.
**
** This routine is a defense against programming errors.







>







172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
  {  'G',  0, 1, etGENERIC,    14, 0 },
  {  'i', 10, 1, etRADIX,      0,  0 },
  {  'n',  0, 0, etSIZE,       0,  0 },
  {  '%',  0, 0, etPERCENT,    0,  0 },
  {  'p', 16, 0, etPOINTER,    0,  1 },
  {  '/',  0, 0, etPATH,       0,  0 },
  {  '$',  0, 0, etSHELLESC,   0,  0 },
  {  etERROR, 0,0,0,0,0}  /* Must be last */
};
#define etNINFO count(fmtinfo)

/*
** Verify that the fmtchr[] and fmtinfo[] arrays are in agreement.
**
** This routine is a defense against programming errors.
327
328
329
330
331
332
333
334
335

336

337

338
339
340
341
342
343
344
345
346
347
  int nsd;                   /* Number of significant digits returned */
  char *zFmtLookup;

  count = length = 0;
  bufpt = 0;
  for(; (c=(*fmt))!=0; ++fmt){
    if( c!='%' ){
      int amt;
      bufpt = (char *)fmt;

      amt = 1;

      while( (c=(*++fmt))!='%' && c!=0 ) amt++;

      blob_append(pBlob,bufpt,amt);
      count += amt;
      if( c==0 ) break;
    }
    if( (c=(*++fmt))==0 ){
      errorflag = 1;
      blob_append(pBlob,"%",1);
      count++;
      break;
    }







<

>
|
>
|
>
|
<
|







328
329
330
331
332
333
334

335
336
337
338
339
340
341

342
343
344
345
346
347
348
349
  int nsd;                   /* Number of significant digits returned */
  char *zFmtLookup;

  count = length = 0;
  bufpt = 0;
  for(; (c=(*fmt))!=0; ++fmt){
    if( c!='%' ){

      bufpt = (char *)fmt;
#if HAVE_STRCHRNUL
      fmt = strchrnul(fmt, '%');
#else
      do{ fmt++; }while( *fmt && *fmt != '%' );
#endif
      blob_append(pBlob, bufpt, (int)(fmt - bufpt));

      if( *fmt==0 ) break;
    }
    if( (c=(*++fmt))==0 ){
      errorflag = 1;
      blob_append(pBlob,"%",1);
      count++;
      break;
    }