commit - f6db314590fc96c0cdbf87367b47da8603e17ae9
commit + 7280e29c8ed198cf9253d84bb9289e55adaabf12
blob - 5eaebfacda33fd3b4931e4077bfad705adb4803c
blob + a286036a2ee2b4911b7aa95172020f4192c56f5d
--- lib/diff_myers.c
+++ lib/diff_myers.c
int x_before_slide;
*found_midpoint = false;
- debug("-- %s d=%d\n", __func__, d);
-
for (k = d; k >= -d; k -= 2) {
if (k < -(int)right->atoms.len || k > (int)left->atoms.len) {
/* This diagonal is completely outside of the Myers
* graph, don't calculate it. */
- if (k < -(int)right->atoms.len)
- debug(" %d k < -(int)right->atoms.len %d\n", k,
- -(int)right->atoms.len);
- else
- debug(" %d k > left->atoms.len %d\n", k,
- left->atoms.len);
if (k < 0) {
/* We are traversing negatively, and already
* below the entire graph, nothing will come of
debug(" continue\n");
continue;
}
- debug("- k = %d\n", k);
if (d == 0) {
/* This is the initializing step. There is no prev_k
* yet, get the initial x from the top left of the Myers
x++;
}
kd_forward[k] = x;
+#if 0
if (x_before_slide != x) {
debug(" down %d similar lines\n", x - x_before_slide);
}
}
}
#endif
+#endif
if (x < 0 || x > left->atoms.len
|| xk_to_y(x, k) < 0 || xk_to_y(x, k) > right->atoms.len)
int backwards_d = d - 1;
if (backwards_d < 0)
continue;
-
- debug("backwards_d = %d\n", backwards_d);
/* If both sides have the same length, forward and backward
* start on the same diagonal, meaning the backwards state index
* it reaches when sliding down identical lines.
*/
int backward_x = kd_backward[c];
- debug("Compare: k=%d c=%d is (%d,%d) >= (%d,%d)?\n",
- k, c, x, xk_to_y(x, k), backward_x,
- xc_to_y(backward_x, c, delta));
if (x >= backward_x) {
if (x_before_slide != x) {
/* met after sliding up a mid-snake */
}
}
- debug_dump_myers_graph(left, right, NULL, kd_forward, d,
- kd_backward, d-1);
return 0;
}
*found_midpoint = false;
- debug("-- %s d=%d\n", __func__, d);
-
for (c = d; c >= -d; c -= 2) {
if (c < -(int)left->atoms.len || c > (int)right->atoms.len) {
/* This diagonal is completely outside of the Myers
* graph, don't calculate it. */
- if (c < -(int)left->atoms.len)
- debug(" %d c < -(int)left->atoms.len %d\n", c,
- -(int)left->atoms.len);
- else
- debug(" %d c > right->atoms.len %d\n", c,
- right->atoms.len);
if (c < 0) {
/* We are traversing negatively, and already
* below the entire graph, nothing will come of
* this. */
- debug(" break\n");
break;
}
- debug(" continue\n");
continue;
}
- debug("- c = %d\n", c);
if (d == 0) {
/* This is the initializing step. There is no prev_c
* yet, get the initial x from the bottom right of the
/* Slide up any snake that we might find here (sections of
* identical lines on both sides). */
+#if 0
debug("c=%d x-1=%d Yb-1=%d-1=%d\n", c, x-1, xc_to_y(x, c,
delta),
xc_to_y(x, c, delta)-1);
debug_dump_atom(right, left,
&right->atoms.head[xc_to_y(x, c, delta)-1]);
}
+#endif
x_before_slide = x;
while (x > 0 && xc_to_y(x, c, delta) > 0) {
bool same;
x--;
}
kd_backward[c] = x;
+#if 0
if (x_before_slide != x) {
debug(" up %d similar lines\n", x_before_slide - x);
}
kd_backward[fi] - fi + delta);
}
}
+#endif
if (x < 0 || x > left->atoms.len
|| xc_to_y(x, c, delta) < 0
*/
int forward_x = kd_forward[k];
- debug("Compare: k=%d c=%d is (%d,%d) >= (%d,%d)?\n",
- k, c, forward_x, xk_to_y(forward_x, k),
- x, xc_to_y(x, c, delta));
if (forward_x >= x) {
if (x_before_slide != x) {
/* met after sliding down a mid-snake */
}
}
}
- debug_dump_myers_graph(left, right, NULL, kd_forward, d, kd_backward,
- d);
return 0;
}
debug_dump(left);
debug("right:\n");
debug_dump(right);
- debug_dump_myers_graph(left, right, NULL, NULL, 0, NULL, 0);
/* Allocate two columns of a Myers graph, one for the forward and one
* for the backward traversal. */
bool found_midpoint = false;
for (d = 0; d <= (max/2); d++) {
int r;
- debug("-- d=%d\n", d);
r = diff_divide_myers_forward(&found_midpoint, left, right,
kd_forward, kd_backward, d,
&mid_snake);
int k;
int x, y;
for (d = 0; d <= max; d++, kd_column += kd_len) {
- debug("-- d=%d\n", d);
-
debug("-- %s d=%d\n", __func__, d);
for (k = d; k >= -d; k -= 2) {
continue;
}
- debug("- k = %d\n", k);
if (d == 0) {
/* This is the initializing step. There is no
* prev_k yet, get the initial x from the top
}
kd_column[k] = x;
- if (DEBUG) {
- int fi;
- for (fi = d; fi >= k; fi-=2) {
- debug("kd_column[%d] = (%d, %d)\n", fi,
- kd_column[fi],
- kd_column[fi] - fi);
- }
- }
-
if (x == left->atoms.len
&& xk_to_y(x, k) == right->atoms.len) {
/* Found a path */