Fossil SCM

More tweaks to the diff alignment algorithm.

drh 2021-09-11 19:51 trunk
Commit f9cc72fffab16f795924032fc4be0bb00d189b3a39a556ef0a57e551bb8986de
1 file changed +3 -3
+3 -3
--- src/diff.c
+++ src/diff.c
@@ -1758,16 +1758,16 @@
17581758
if( nB>250 ) nB = 250;
17591759
avg = (nA+nB)/2;
17601760
if( avg==0 ) return 0;
17611761
nMin = nA;
17621762
if( nB<nMin ) nMin = nB;
1763
- if( nMin==0 ) return 62;
1763
+ if( nMin==0 ) return 68;
17641764
for(nPrefix=0; nPrefix<nMin && zA[nPrefix]==zB[nPrefix]; nPrefix++){}
17651765
best = 0;
17661766
if( nPrefix>5 && nPrefix>nMin/2 ){
17671767
best = nPrefix*3/2;
1768
- if( best>=avg ) best = avg - 2;
1768
+ if( best>=avg - 2 ) best = avg - 2;
17691769
}
17701770
if( nA==nB && memcmp(zA, zB, nA)==0 ) return 0;
17711771
memset(aFirst, 0xff, sizeof(aFirst));
17721772
zA--; zB--; /* Make both zA[] and zB[] 1-indexed */
17731773
for(i=nB; i>0; i--){
@@ -1955,11 +1955,11 @@
19551955
m = a[i]+50;
19561956
d = 1;
19571957
}
19581958
if( m>p ){
19591959
int score = match_dline(&aLeft[j-1], &aRight[i-1]);
1960
- if( (score<=63 || (i<j+1 && i>j-1)) && m>p+score ){
1960
+ if( (score<=90 || (i<j+1 && i>j-1)) && m>p+score ){
19611961
m = p+score;
19621962
d = 3 | score*4;
19631963
}
19641964
}
19651965
p = a[i];
19661966
--- src/diff.c
+++ src/diff.c
@@ -1758,16 +1758,16 @@
1758 if( nB>250 ) nB = 250;
1759 avg = (nA+nB)/2;
1760 if( avg==0 ) return 0;
1761 nMin = nA;
1762 if( nB<nMin ) nMin = nB;
1763 if( nMin==0 ) return 62;
1764 for(nPrefix=0; nPrefix<nMin && zA[nPrefix]==zB[nPrefix]; nPrefix++){}
1765 best = 0;
1766 if( nPrefix>5 && nPrefix>nMin/2 ){
1767 best = nPrefix*3/2;
1768 if( best>=avg ) best = avg - 2;
1769 }
1770 if( nA==nB && memcmp(zA, zB, nA)==0 ) return 0;
1771 memset(aFirst, 0xff, sizeof(aFirst));
1772 zA--; zB--; /* Make both zA[] and zB[] 1-indexed */
1773 for(i=nB; i>0; i--){
@@ -1955,11 +1955,11 @@
1955 m = a[i]+50;
1956 d = 1;
1957 }
1958 if( m>p ){
1959 int score = match_dline(&aLeft[j-1], &aRight[i-1]);
1960 if( (score<=63 || (i<j+1 && i>j-1)) && m>p+score ){
1961 m = p+score;
1962 d = 3 | score*4;
1963 }
1964 }
1965 p = a[i];
1966
--- src/diff.c
+++ src/diff.c
@@ -1758,16 +1758,16 @@
1758 if( nB>250 ) nB = 250;
1759 avg = (nA+nB)/2;
1760 if( avg==0 ) return 0;
1761 nMin = nA;
1762 if( nB<nMin ) nMin = nB;
1763 if( nMin==0 ) return 68;
1764 for(nPrefix=0; nPrefix<nMin && zA[nPrefix]==zB[nPrefix]; nPrefix++){}
1765 best = 0;
1766 if( nPrefix>5 && nPrefix>nMin/2 ){
1767 best = nPrefix*3/2;
1768 if( best>=avg - 2 ) best = avg - 2;
1769 }
1770 if( nA==nB && memcmp(zA, zB, nA)==0 ) return 0;
1771 memset(aFirst, 0xff, sizeof(aFirst));
1772 zA--; zB--; /* Make both zA[] and zB[] 1-indexed */
1773 for(i=nB; i>0; i--){
@@ -1955,11 +1955,11 @@
1955 m = a[i]+50;
1956 d = 1;
1957 }
1958 if( m>p ){
1959 int score = match_dline(&aLeft[j-1], &aRight[i-1]);
1960 if( (score<=90 || (i<j+1 && i>j-1)) && m>p+score ){
1961 m = p+score;
1962 d = 3 | score*4;
1963 }
1964 }
1965 p = a[i];
1966

Keyboard Shortcuts

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