Skip to content

Commit 7fc0b33

Browse files
committed
Merge branch 'yc/xdiff-patience-optim'
The way patience diff finds LCS has been optimized. * yc/xdiff-patience-optim: xdiff: optimize patience diff's LCS search
2 parents fe0e6ff + c7e3b80 commit 7fc0b33

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

xdiff/xpatience.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ static int find_longest_common_sequence(struct hashmap *map, struct entry **res)
211211
for (entry = map->first; entry; entry = entry->next) {
212212
if (!entry->line2 || entry->line2 == NON_UNIQUE)
213213
continue;
214-
i = binary_search(sequence, longest, entry);
214+
if (longest == 0 || entry->line2 > sequence[longest - 1]->line2)
215+
i = longest - 1;
216+
else
217+
i = binary_search(sequence, longest, entry);
215218
entry->previous = i < 0 ? NULL : sequence[i];
216219
++i;
217220
if (i <= anchor_i)

0 commit comments

Comments
 (0)