Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Another minor performance enhancement on sbs diff. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
3e3feb2dda2c95070e0d34dc7d5ec430 |
| User & Date: | drh 2012-02-07 20:04:29.842 |
Context
|
2012-02-08
| ||
| 00:34 | Fix issues with the --brief option to the diff command. ... (check-in: fbaa7ca99f user: drh tags: trunk) | |
|
2012-02-07
| ||
| 20:04 | Another minor performance enhancement on sbs diff. ... (check-in: 3e3feb2dda user: drh tags: trunk) | |
| 18:58 | Performance optimization for the alignment calculation on side-by-side diffs. Noticably faster. ... (check-in: 87f867018b user: drh tags: trunk) | |
Changes
Changes to src/diff.c.
| ︙ | ︙ | |||
574 575 576 577 578 579 580 |
while( nB>0 && fossil_isspace(zB[0]) ){ nB--; zB++; }
while( nB>0 && fossil_isspace(zB[nB-1]) ){ nB--; }
if( nA>250 ) nA = 250;
if( nB>250 ) nB = 250;
avg = (nA+nB)/2;
if( avg==0 ) return 0;
memset(aFirst, 0, sizeof(aFirst));
| < | | | | | 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
while( nB>0 && fossil_isspace(zB[0]) ){ nB--; zB++; }
while( nB>0 && fossil_isspace(zB[nB-1]) ){ nB--; }
if( nA>250 ) nA = 250;
if( nB>250 ) nB = 250;
avg = (nA+nB)/2;
if( avg==0 ) return 0;
memset(aFirst, 0, sizeof(aFirst));
zA--; zB--; /* Make both zA[] and zB[] 1-indexed */
for(i=nB; i>0; i--){
c = (unsigned char)zB[i];
aNext[i] = aFirst[c];
aFirst[c] = i;
}
best = 0;
for(i=1; i<=nA-best; i++){
c = (unsigned char)zA[i];
for(j=aFirst[c]; j>0 && j<nB-best; j = aNext[j]){
int limit = minInt(nA-i, nB-j);
for(k=1; k<=limit && zA[k+i]==zB[k+j]; k++){}
if( k>best ) best = k;
}
}
score = (best>avg) ? 0 : (avg - best)*100/avg;
#if 0
fprintf(stderr, "A: [%.*s]\nB: [%.*s]\nbest=%d avg=%d score=%d\n",
|
| ︙ | ︙ |