Fossil SCM
Performance optimizations for the delta generator.
Commit
dbbe320297e55cb4396cd6c2461deb806cdf2f4d
Parent
e4e09884778787f…
1 file changed
+5
-2
+5
-2
| --- src/delta.c | ||
| +++ src/delta.c | ||
| @@ -389,18 +389,21 @@ | ||
| 389 | 389 | ** copy command is less than the amount of literal text to be copied. |
| 390 | 390 | */ |
| 391 | 391 | int cnt, ofst, litsz; |
| 392 | 392 | int j, k, x, y; |
| 393 | 393 | int sz; |
| 394 | + int limitX; | |
| 394 | 395 | |
| 395 | 396 | /* Beginning at iSrc, match forwards as far as we can. j counts |
| 396 | 397 | ** the number of characters that match */ |
| 397 | 398 | iSrc = iBlock*NHASH; |
| 398 | - for(j=0, x=iSrc, y=base+i; x<lenSrc && y<lenOut; j++, x++, y++){ | |
| 399 | + y = base+i; | |
| 400 | + limitX = ( lenSrc-iSrc <= lenOut-y ) ? lenSrc : iSrc + lenOut - y; | |
| 401 | + for(x=iSrc; x<limitX; x++, y++){ | |
| 399 | 402 | if( zSrc[x]!=zOut[y] ) break; |
| 400 | 403 | } |
| 401 | - j--; | |
| 404 | + j = x - iSrc - 1; | |
| 402 | 405 | |
| 403 | 406 | /* Beginning at iSrc-1, match backwards as far as we can. k counts |
| 404 | 407 | ** the number of characters that match */ |
| 405 | 408 | for(k=1; k<iSrc && k<=i; k++){ |
| 406 | 409 | if( zSrc[iSrc-k]!=zOut[base+i-k] ) break; |
| 407 | 410 |
| --- src/delta.c | |
| +++ src/delta.c | |
| @@ -389,18 +389,21 @@ | |
| 389 | ** copy command is less than the amount of literal text to be copied. |
| 390 | */ |
| 391 | int cnt, ofst, litsz; |
| 392 | int j, k, x, y; |
| 393 | int sz; |
| 394 | |
| 395 | /* Beginning at iSrc, match forwards as far as we can. j counts |
| 396 | ** the number of characters that match */ |
| 397 | iSrc = iBlock*NHASH; |
| 398 | for(j=0, x=iSrc, y=base+i; x<lenSrc && y<lenOut; j++, x++, y++){ |
| 399 | if( zSrc[x]!=zOut[y] ) break; |
| 400 | } |
| 401 | j--; |
| 402 | |
| 403 | /* Beginning at iSrc-1, match backwards as far as we can. k counts |
| 404 | ** the number of characters that match */ |
| 405 | for(k=1; k<iSrc && k<=i; k++){ |
| 406 | if( zSrc[iSrc-k]!=zOut[base+i-k] ) break; |
| 407 |
| --- src/delta.c | |
| +++ src/delta.c | |
| @@ -389,18 +389,21 @@ | |
| 389 | ** copy command is less than the amount of literal text to be copied. |
| 390 | */ |
| 391 | int cnt, ofst, litsz; |
| 392 | int j, k, x, y; |
| 393 | int sz; |
| 394 | int limitX; |
| 395 | |
| 396 | /* Beginning at iSrc, match forwards as far as we can. j counts |
| 397 | ** the number of characters that match */ |
| 398 | iSrc = iBlock*NHASH; |
| 399 | y = base+i; |
| 400 | limitX = ( lenSrc-iSrc <= lenOut-y ) ? lenSrc : iSrc + lenOut - y; |
| 401 | for(x=iSrc; x<limitX; x++, y++){ |
| 402 | if( zSrc[x]!=zOut[y] ) break; |
| 403 | } |
| 404 | j = x - iSrc - 1; |
| 405 | |
| 406 | /* Beginning at iSrc-1, match backwards as far as we can. k counts |
| 407 | ** the number of characters that match */ |
| 408 | for(k=1; k<iSrc && k<=i; k++){ |
| 409 | if( zSrc[iSrc-k]!=zOut[base+i-k] ) break; |
| 410 |