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
This commit is contained in:
Junio C Hamano
2025-12-09 07:54:55 +09:00

View File

@@ -211,6 +211,9 @@ static int find_longest_common_sequence(struct hashmap *map, struct entry **res)
for (entry = map->first; entry; entry = entry->next) { for (entry = map->first; entry; entry = entry->next) {
if (!entry->line2 || entry->line2 == NON_UNIQUE) if (!entry->line2 || entry->line2 == NON_UNIQUE)
continue; continue;
if (longest == 0 || entry->line2 > sequence[longest - 1]->line2)
i = longest - 1;
else
i = binary_search(sequence, longest, entry); i = binary_search(sequence, longest, entry);
entry->previous = i < 0 ? NULL : sequence[i]; entry->previous = i < 0 ? NULL : sequence[i];
++i; ++i;