Fossil SCM
Further performance improvements to the internal printf() implementation.
Commit
3ad620df0058144d39fd950d819f2dc10cab1185a04ce3965833ab6f5cc19af2
Parent
008fc9290cbbaa5…
1 file changed
+8
-6
+8
-6
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -174,10 +174,11 @@ | ||
| 174 | 174 | { 'n', 0, 0, etSIZE, 0, 0 }, |
| 175 | 175 | { '%', 0, 0, etPERCENT, 0, 0 }, |
| 176 | 176 | { 'p', 16, 0, etPOINTER, 0, 1 }, |
| 177 | 177 | { '/', 0, 0, etPATH, 0, 0 }, |
| 178 | 178 | { '$', 0, 0, etSHELLESC, 0, 0 }, |
| 179 | + { etERROR, 0,0,0,0,0} /* Must be last */ | |
| 179 | 180 | }; |
| 180 | 181 | #define etNINFO count(fmtinfo) |
| 181 | 182 | |
| 182 | 183 | /* |
| 183 | 184 | ** Verify that the fmtchr[] and fmtinfo[] arrays are in agreement. |
| @@ -329,17 +330,18 @@ | ||
| 329 | 330 | |
| 330 | 331 | count = length = 0; |
| 331 | 332 | bufpt = 0; |
| 332 | 333 | for(; (c=(*fmt))!=0; ++fmt){ |
| 333 | 334 | if( c!='%' ){ |
| 334 | - int amt; | |
| 335 | 335 | bufpt = (char *)fmt; |
| 336 | - amt = 1; | |
| 337 | - while( (c=(*++fmt))!='%' && c!=0 ) amt++; | |
| 338 | - blob_append(pBlob,bufpt,amt); | |
| 339 | - count += amt; | |
| 340 | - if( c==0 ) break; | |
| 336 | +#if HAVE_STRCHRNUL | |
| 337 | + fmt = strchrnul(fmt, '%'); | |
| 338 | +#else | |
| 339 | + do{ fmt++; }while( *fmt && *fmt != '%' ); | |
| 340 | +#endif | |
| 341 | + blob_append(pBlob, bufpt, (int)(fmt - bufpt)); | |
| 342 | + if( *fmt==0 ) break; | |
| 341 | 343 | } |
| 342 | 344 | if( (c=(*++fmt))==0 ){ |
| 343 | 345 | errorflag = 1; |
| 344 | 346 | blob_append(pBlob,"%",1); |
| 345 | 347 | count++; |
| 346 | 348 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -174,10 +174,11 @@ | |
| 174 | { 'n', 0, 0, etSIZE, 0, 0 }, |
| 175 | { '%', 0, 0, etPERCENT, 0, 0 }, |
| 176 | { 'p', 16, 0, etPOINTER, 0, 1 }, |
| 177 | { '/', 0, 0, etPATH, 0, 0 }, |
| 178 | { '$', 0, 0, etSHELLESC, 0, 0 }, |
| 179 | }; |
| 180 | #define etNINFO count(fmtinfo) |
| 181 | |
| 182 | /* |
| 183 | ** Verify that the fmtchr[] and fmtinfo[] arrays are in agreement. |
| @@ -329,17 +330,18 @@ | |
| 329 | |
| 330 | count = length = 0; |
| 331 | bufpt = 0; |
| 332 | for(; (c=(*fmt))!=0; ++fmt){ |
| 333 | if( c!='%' ){ |
| 334 | int amt; |
| 335 | bufpt = (char *)fmt; |
| 336 | amt = 1; |
| 337 | while( (c=(*++fmt))!='%' && c!=0 ) amt++; |
| 338 | blob_append(pBlob,bufpt,amt); |
| 339 | count += amt; |
| 340 | if( c==0 ) break; |
| 341 | } |
| 342 | if( (c=(*++fmt))==0 ){ |
| 343 | errorflag = 1; |
| 344 | blob_append(pBlob,"%",1); |
| 345 | count++; |
| 346 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -174,10 +174,11 @@ | |
| 174 | { 'n', 0, 0, etSIZE, 0, 0 }, |
| 175 | { '%', 0, 0, etPERCENT, 0, 0 }, |
| 176 | { 'p', 16, 0, etPOINTER, 0, 1 }, |
| 177 | { '/', 0, 0, etPATH, 0, 0 }, |
| 178 | { '$', 0, 0, etSHELLESC, 0, 0 }, |
| 179 | { etERROR, 0,0,0,0,0} /* Must be last */ |
| 180 | }; |
| 181 | #define etNINFO count(fmtinfo) |
| 182 | |
| 183 | /* |
| 184 | ** Verify that the fmtchr[] and fmtinfo[] arrays are in agreement. |
| @@ -329,17 +330,18 @@ | |
| 330 | |
| 331 | count = length = 0; |
| 332 | bufpt = 0; |
| 333 | for(; (c=(*fmt))!=0; ++fmt){ |
| 334 | if( c!='%' ){ |
| 335 | bufpt = (char *)fmt; |
| 336 | #if HAVE_STRCHRNUL |
| 337 | fmt = strchrnul(fmt, '%'); |
| 338 | #else |
| 339 | do{ fmt++; }while( *fmt && *fmt != '%' ); |
| 340 | #endif |
| 341 | blob_append(pBlob, bufpt, (int)(fmt - bufpt)); |
| 342 | if( *fmt==0 ) break; |
| 343 | } |
| 344 | if( (c=(*++fmt))==0 ){ |
| 345 | errorflag = 1; |
| 346 | blob_append(pBlob,"%",1); |
| 347 | count++; |
| 348 |