Fossil SCM

Add a #define for the diff block alignment algorithm threshold.

drh 2021-09-05 19:16 trunk
Commit 0a4ae4408efc839a4e61b9ca9f252e6dd33fab979ca6cc8b6f9e7a025ae3b086
1 file changed +8 -1
+8 -1
--- src/diff.c
+++ src/diff.c
@@ -1733,10 +1733,17 @@
17331733
b.n = (int)strlen(b.z);
17341734
x = match_dline(&a, &b);
17351735
fossil_print("%d\n", x);
17361736
}
17371737
1738
+/*
1739
+** The threshold at which diffBlockAlignment transitions from the
1740
+** O(N*N) Wagner minimum-edit-distance algorithm to a less process
1741
+** O(NlogN) divide-and-conquer approach.
1742
+*/
1743
+#define DIFF_ALIGN_MX 1225
1744
+
17381745
/*
17391746
** There is a change block in which nLeft lines of text on the left are
17401747
** converted into nRight lines of text on the right. This routine computes
17411748
** how the lines on the left line up with the lines on the right.
17421749
**
@@ -1791,11 +1798,11 @@
17911798
** O(NlogN). The result is not as precise, but this whole thing is an
17921799
** approximation anyhow, and the faster response time is an acceptable
17931800
** trade-off for reduced precision.
17941801
*/
17951802
mnLen = nLeft<nRight ? nLeft : nRight;
1796
- if( nLeft*nRight>1000 && (diffFlags & DIFF_SLOW_SBS)==0 ){
1803
+ if( nLeft*nRight>DIFF_ALIGN_MX && (diffFlags & DIFF_SLOW_SBS)==0 ){
17971804
const DLine *aSmall; /* The smaller of aLeft and aRight */
17981805
const DLine *aBig; /* The larger of aLeft and aRight */
17991806
int nSmall, nBig; /* Size of aSmall and aBig. nSmall<=nBig */
18001807
int iDivSmall, iDivBig; /* Divider point for aSmall and aBig */
18011808
int iDivLeft, iDivRight; /* Divider point for aLeft and aRight */
18021809
--- src/diff.c
+++ src/diff.c
@@ -1733,10 +1733,17 @@
1733 b.n = (int)strlen(b.z);
1734 x = match_dline(&a, &b);
1735 fossil_print("%d\n", x);
1736 }
1737
 
 
 
 
 
 
 
1738 /*
1739 ** There is a change block in which nLeft lines of text on the left are
1740 ** converted into nRight lines of text on the right. This routine computes
1741 ** how the lines on the left line up with the lines on the right.
1742 **
@@ -1791,11 +1798,11 @@
1791 ** O(NlogN). The result is not as precise, but this whole thing is an
1792 ** approximation anyhow, and the faster response time is an acceptable
1793 ** trade-off for reduced precision.
1794 */
1795 mnLen = nLeft<nRight ? nLeft : nRight;
1796 if( nLeft*nRight>1000 && (diffFlags & DIFF_SLOW_SBS)==0 ){
1797 const DLine *aSmall; /* The smaller of aLeft and aRight */
1798 const DLine *aBig; /* The larger of aLeft and aRight */
1799 int nSmall, nBig; /* Size of aSmall and aBig. nSmall<=nBig */
1800 int iDivSmall, iDivBig; /* Divider point for aSmall and aBig */
1801 int iDivLeft, iDivRight; /* Divider point for aLeft and aRight */
1802
--- src/diff.c
+++ src/diff.c
@@ -1733,10 +1733,17 @@
1733 b.n = (int)strlen(b.z);
1734 x = match_dline(&a, &b);
1735 fossil_print("%d\n", x);
1736 }
1737
1738 /*
1739 ** The threshold at which diffBlockAlignment transitions from the
1740 ** O(N*N) Wagner minimum-edit-distance algorithm to a less process
1741 ** O(NlogN) divide-and-conquer approach.
1742 */
1743 #define DIFF_ALIGN_MX 1225
1744
1745 /*
1746 ** There is a change block in which nLeft lines of text on the left are
1747 ** converted into nRight lines of text on the right. This routine computes
1748 ** how the lines on the left line up with the lines on the right.
1749 **
@@ -1791,11 +1798,11 @@
1798 ** O(NlogN). The result is not as precise, but this whole thing is an
1799 ** approximation anyhow, and the faster response time is an acceptable
1800 ** trade-off for reduced precision.
1801 */
1802 mnLen = nLeft<nRight ? nLeft : nRight;
1803 if( nLeft*nRight>DIFF_ALIGN_MX && (diffFlags & DIFF_SLOW_SBS)==0 ){
1804 const DLine *aSmall; /* The smaller of aLeft and aRight */
1805 const DLine *aBig; /* The larger of aLeft and aRight */
1806 int nSmall, nBig; /* Size of aSmall and aBig. nSmall<=nBig */
1807 int iDivSmall, iDivBig; /* Divider point for aSmall and aBig */
1808 int iDivLeft, iDivRight; /* Divider point for aLeft and aRight */
1809

Keyboard Shortcuts

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