Fossil SCM
Approximately a 5x performance increase for diff with the -w (ignore whitespace) option.
Commit
fbdbc09b402b19de63889436358041870aa6efe2a9bca7dd16db345ed8e1538c
Parent
cf69ac4e394c668…
1 file changed
+4
-2
+4
-2
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -323,14 +323,16 @@ | ||
| 323 | 323 | /* |
| 324 | 324 | ** Return zero if two DLine elements are identical, ignoring |
| 325 | 325 | ** all whitespace. The indent field of pA/pB already points |
| 326 | 326 | ** to the first non-space character in the string. |
| 327 | 327 | */ |
| 328 | - | |
| 329 | 328 | static int compare_dline_ignore_allws(const DLine *pA, const DLine *pB){ |
| 330 | - int a = pA->indent, b = pB->indent; | |
| 331 | 329 | if( pA->h==pB->h ){ |
| 330 | + int a, b; | |
| 331 | + if( memcmp(pA->z, pB->z, pA->h&LENGTH_MASK)==0 ) return 0; | |
| 332 | + a = pA->indent; | |
| 333 | + b = pB->indent; | |
| 332 | 334 | while( a<pA->n || b<pB->n ){ |
| 333 | 335 | if( a<pA->n && b<pB->n && pA->z[a++] != pB->z[b++] ) return 1; |
| 334 | 336 | while( a<pA->n && diff_isspace(pA->z[a])) ++a; |
| 335 | 337 | while( b<pB->n && diff_isspace(pB->z[b])) ++b; |
| 336 | 338 | } |
| 337 | 339 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -323,14 +323,16 @@ | |
| 323 | /* |
| 324 | ** Return zero if two DLine elements are identical, ignoring |
| 325 | ** all whitespace. The indent field of pA/pB already points |
| 326 | ** to the first non-space character in the string. |
| 327 | */ |
| 328 | |
| 329 | static int compare_dline_ignore_allws(const DLine *pA, const DLine *pB){ |
| 330 | int a = pA->indent, b = pB->indent; |
| 331 | if( pA->h==pB->h ){ |
| 332 | while( a<pA->n || b<pB->n ){ |
| 333 | if( a<pA->n && b<pB->n && pA->z[a++] != pB->z[b++] ) return 1; |
| 334 | while( a<pA->n && diff_isspace(pA->z[a])) ++a; |
| 335 | while( b<pB->n && diff_isspace(pB->z[b])) ++b; |
| 336 | } |
| 337 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -323,14 +323,16 @@ | |
| 323 | /* |
| 324 | ** Return zero if two DLine elements are identical, ignoring |
| 325 | ** all whitespace. The indent field of pA/pB already points |
| 326 | ** to the first non-space character in the string. |
| 327 | */ |
| 328 | static int compare_dline_ignore_allws(const DLine *pA, const DLine *pB){ |
| 329 | if( pA->h==pB->h ){ |
| 330 | int a, b; |
| 331 | if( memcmp(pA->z, pB->z, pA->h&LENGTH_MASK)==0 ) return 0; |
| 332 | a = pA->indent; |
| 333 | b = pB->indent; |
| 334 | while( a<pA->n || b<pB->n ){ |
| 335 | if( a<pA->n && b<pB->n && pA->z[a++] != pB->z[b++] ) return 1; |
| 336 | while( a<pA->n && diff_isspace(pA->z[a])) ++a; |
| 337 | while( b<pB->n && diff_isspace(pB->z[b])) ++b; |
| 338 | } |
| 339 |