Fossil SCM

Performance optimizations for the delta generator.

drh 2015-12-27 20:05 trunk
Commit dbbe320297e55cb4396cd6c2461deb806cdf2f4d
1 file changed +5 -2
+5 -2
--- src/delta.c
+++ src/delta.c
@@ -389,18 +389,21 @@
389389
** copy command is less than the amount of literal text to be copied.
390390
*/
391391
int cnt, ofst, litsz;
392392
int j, k, x, y;
393393
int sz;
394
+ int limitX;
394395
395396
/* Beginning at iSrc, match forwards as far as we can. j counts
396397
** the number of characters that match */
397398
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++){
399402
if( zSrc[x]!=zOut[y] ) break;
400403
}
401
- j--;
404
+ j = x - iSrc - 1;
402405
403406
/* Beginning at iSrc-1, match backwards as far as we can. k counts
404407
** the number of characters that match */
405408
for(k=1; k<iSrc && k<=i; k++){
406409
if( zSrc[iSrc-k]!=zOut[base+i-k] ) break;
407410
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button