Fossil SCM
Replaced a complicated bit of logic with something slighlty less complicated, having the same effect. The glob parser used a mix of second-clause for-loop testing and internal break and continue checks without any other internal processing inside the loop. Combining all of this into a single expression requires the line to wrap (bad for clarity) but it does make clear all of the conditions required for this loop to continue iterating. I think it's a net improvement in clarity, though the margin is admittedly small. Testing shows no regression in functionality, limiting this non-functional change to a style improvement.
Commit
b878923997bbcf1eded6861a357b5ab454bb442369effe1c9eea20f2d9498393
Parent
8ce70b4c0c19d7b…
1 file changed
+4
-4
+4
-4
| --- src/glob.c | ||
| +++ src/glob.c | ||
| @@ -126,14 +126,14 @@ | ||
| 126 | 126 | }else{ |
| 127 | 127 | delimiter = ','; |
| 128 | 128 | } |
| 129 | 129 | p->azPattern = fossil_realloc(p->azPattern, (p->nPattern+1)*sizeof(char*) ); |
| 130 | 130 | p->azPattern[p->nPattern++] = z; |
| 131 | - /* Find the next delimter (or the end of the string). */ | |
| 132 | - for(i=0; z[i] && z[i]!=delimiter; i++){ | |
| 133 | - if( delimiter!=',' ) continue; /* If quoted, keep going. */ | |
| 134 | - if( fossil_isspace(z[i]) ) break; /* If space, stop. */ | |
| 131 | + /* Find the next delimiter (or the end of the string). */ | |
| 132 | + for(i=0; z[i] && z[i]!=delimiter && | |
| 133 | + !(delimiter==',' && fossil_isspace(z[i])); i++){ | |
| 134 | + /* keep looking for the end of the glob pattern */ | |
| 135 | 135 | } |
| 136 | 136 | if( z[i]==0 ) break; |
| 137 | 137 | z[i] = 0; |
| 138 | 138 | z += i+1; |
| 139 | 139 | } |
| 140 | 140 |
| --- src/glob.c | |
| +++ src/glob.c | |
| @@ -126,14 +126,14 @@ | |
| 126 | }else{ |
| 127 | delimiter = ','; |
| 128 | } |
| 129 | p->azPattern = fossil_realloc(p->azPattern, (p->nPattern+1)*sizeof(char*) ); |
| 130 | p->azPattern[p->nPattern++] = z; |
| 131 | /* Find the next delimter (or the end of the string). */ |
| 132 | for(i=0; z[i] && z[i]!=delimiter; i++){ |
| 133 | if( delimiter!=',' ) continue; /* If quoted, keep going. */ |
| 134 | if( fossil_isspace(z[i]) ) break; /* If space, stop. */ |
| 135 | } |
| 136 | if( z[i]==0 ) break; |
| 137 | z[i] = 0; |
| 138 | z += i+1; |
| 139 | } |
| 140 |
| --- src/glob.c | |
| +++ src/glob.c | |
| @@ -126,14 +126,14 @@ | |
| 126 | }else{ |
| 127 | delimiter = ','; |
| 128 | } |
| 129 | p->azPattern = fossil_realloc(p->azPattern, (p->nPattern+1)*sizeof(char*) ); |
| 130 | p->azPattern[p->nPattern++] = z; |
| 131 | /* Find the next delimiter (or the end of the string). */ |
| 132 | for(i=0; z[i] && z[i]!=delimiter && |
| 133 | !(delimiter==',' && fossil_isspace(z[i])); i++){ |
| 134 | /* keep looking for the end of the glob pattern */ |
| 135 | } |
| 136 | if( z[i]==0 ) break; |
| 137 | z[i] = 0; |
| 138 | z += i+1; |
| 139 | } |
| 140 |