Fossil SCM
Performance optimization in the building printf() logic makes the "fossil annotate" command run 6x faster.
Commit
1e881f59786bd89129f2b3be03903d0a0d8af7ca0aab00b332941e3126d801c6
Parent
6d0be557dc12a47…
1 file changed
+2
-14
+2
-14
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -198,22 +198,10 @@ | ||
| 198 | 198 | /* |
| 199 | 199 | ** Size of temporary conversion buffer. |
| 200 | 200 | */ |
| 201 | 201 | #define etBUFSIZE 500 |
| 202 | 202 | |
| 203 | -/* | |
| 204 | -** Find the length of a string as long as that length does not | |
| 205 | -** exceed N bytes. If no zero terminator is seen in the first | |
| 206 | -** N bytes then return N. If N is negative, then this routine | |
| 207 | -** is an alias for strlen(). | |
| 208 | -*/ | |
| 209 | -static int StrNLen32(const char *z, int N){ | |
| 210 | - int n = 0; | |
| 211 | - while( (N-- != 0) && *(z++)!=0 ){ n++; } | |
| 212 | - return n; | |
| 213 | -} | |
| 214 | - | |
| 215 | 203 | /* |
| 216 | 204 | ** Return an appropriate set of flags for wiki_convert() for displaying |
| 217 | 205 | ** comments on a timeline. These flag settings are determined by |
| 218 | 206 | ** configuration parameters. |
| 219 | 207 | ** |
| @@ -652,11 +640,11 @@ | ||
| 652 | 640 | case etPATH: { |
| 653 | 641 | int i; |
| 654 | 642 | int limit = flag_alternateform ? va_arg(ap,int) : -1; |
| 655 | 643 | char *e = va_arg(ap,char*); |
| 656 | 644 | if( e==0 ){e="";} |
| 657 | - length = StrNLen32(e, limit); | |
| 645 | + length = (int)strnlen(e,limit); | |
| 658 | 646 | zExtra = bufpt = fossil_malloc(length+1); |
| 659 | 647 | for( i=0; i<length; i++ ){ |
| 660 | 648 | if( e[i]=='\\' ){ |
| 661 | 649 | bufpt[i]='/'; |
| 662 | 650 | }else{ |
| @@ -681,11 +669,11 @@ | ||
| 681 | 669 | }else if( xtype==etDYNSTRING ){ |
| 682 | 670 | zExtra = bufpt; |
| 683 | 671 | }else if( xtype==etSTRINGID ){ |
| 684 | 672 | precision = hash_digits(flag_altform2); |
| 685 | 673 | } |
| 686 | - length = StrNLen32(bufpt, limit); | |
| 674 | + length = (int)strnlen(bufpt,limit); | |
| 687 | 675 | if( precision>=0 && precision<length ) length = precision; |
| 688 | 676 | break; |
| 689 | 677 | } |
| 690 | 678 | case etBLOB: { |
| 691 | 679 | int limit = flag_alternateform ? va_arg(ap, int) : -1; |
| 692 | 680 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -198,22 +198,10 @@ | |
| 198 | /* |
| 199 | ** Size of temporary conversion buffer. |
| 200 | */ |
| 201 | #define etBUFSIZE 500 |
| 202 | |
| 203 | /* |
| 204 | ** Find the length of a string as long as that length does not |
| 205 | ** exceed N bytes. If no zero terminator is seen in the first |
| 206 | ** N bytes then return N. If N is negative, then this routine |
| 207 | ** is an alias for strlen(). |
| 208 | */ |
| 209 | static int StrNLen32(const char *z, int N){ |
| 210 | int n = 0; |
| 211 | while( (N-- != 0) && *(z++)!=0 ){ n++; } |
| 212 | return n; |
| 213 | } |
| 214 | |
| 215 | /* |
| 216 | ** Return an appropriate set of flags for wiki_convert() for displaying |
| 217 | ** comments on a timeline. These flag settings are determined by |
| 218 | ** configuration parameters. |
| 219 | ** |
| @@ -652,11 +640,11 @@ | |
| 652 | case etPATH: { |
| 653 | int i; |
| 654 | int limit = flag_alternateform ? va_arg(ap,int) : -1; |
| 655 | char *e = va_arg(ap,char*); |
| 656 | if( e==0 ){e="";} |
| 657 | length = StrNLen32(e, limit); |
| 658 | zExtra = bufpt = fossil_malloc(length+1); |
| 659 | for( i=0; i<length; i++ ){ |
| 660 | if( e[i]=='\\' ){ |
| 661 | bufpt[i]='/'; |
| 662 | }else{ |
| @@ -681,11 +669,11 @@ | |
| 681 | }else if( xtype==etDYNSTRING ){ |
| 682 | zExtra = bufpt; |
| 683 | }else if( xtype==etSTRINGID ){ |
| 684 | precision = hash_digits(flag_altform2); |
| 685 | } |
| 686 | length = StrNLen32(bufpt, limit); |
| 687 | if( precision>=0 && precision<length ) length = precision; |
| 688 | break; |
| 689 | } |
| 690 | case etBLOB: { |
| 691 | int limit = flag_alternateform ? va_arg(ap, int) : -1; |
| 692 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -198,22 +198,10 @@ | |
| 198 | /* |
| 199 | ** Size of temporary conversion buffer. |
| 200 | */ |
| 201 | #define etBUFSIZE 500 |
| 202 | |
| 203 | /* |
| 204 | ** Return an appropriate set of flags for wiki_convert() for displaying |
| 205 | ** comments on a timeline. These flag settings are determined by |
| 206 | ** configuration parameters. |
| 207 | ** |
| @@ -652,11 +640,11 @@ | |
| 640 | case etPATH: { |
| 641 | int i; |
| 642 | int limit = flag_alternateform ? va_arg(ap,int) : -1; |
| 643 | char *e = va_arg(ap,char*); |
| 644 | if( e==0 ){e="";} |
| 645 | length = (int)strnlen(e,limit); |
| 646 | zExtra = bufpt = fossil_malloc(length+1); |
| 647 | for( i=0; i<length; i++ ){ |
| 648 | if( e[i]=='\\' ){ |
| 649 | bufpt[i]='/'; |
| 650 | }else{ |
| @@ -681,11 +669,11 @@ | |
| 669 | }else if( xtype==etDYNSTRING ){ |
| 670 | zExtra = bufpt; |
| 671 | }else if( xtype==etSTRINGID ){ |
| 672 | precision = hash_digits(flag_altform2); |
| 673 | } |
| 674 | length = (int)strnlen(bufpt,limit); |
| 675 | if( precision>=0 && precision<length ) length = precision; |
| 676 | break; |
| 677 | } |
| 678 | case etBLOB: { |
| 679 | int limit = flag_alternateform ? va_arg(ap, int) : -1; |
| 680 |