@matheusbsbs / matheus-bagliano / commits / 0532a5e46b
Fork 0

diffcore-break: do not break too small filepair.

Somehow we checked only one side and not the other. By checking the filesize upfront, we can bypass generating delta unnecessarily. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 12, 2005 at 17:15 UTC 0532a5e46b88cd70c952a2bf5dc63681be32a2d9
1 file changed +3 -2
diffcore-break.c
+3 -2
@@ -62,6 +62,8 @@ static int should_break(struct diff_filespec *src,
62 return 0; /* error but caught downstream */
63
64 base_size = ((src->size < dst->size) ? src->size : dst->size);
65 + if (base_size < MINIMUM_BREAK_SIZE)
66 + return 0; /* we do not break too small filepair */
67
68 delta = diff_delta(src->data, src->size,
69 dst->data, dst->size,
@@ -170,8 +172,7 @@ void diffcore_break(int break_score)
172 !S_ISDIR(p->one->mode) && !S_ISDIR(p->two->mode) &&
173 !strcmp(p->one->path, p->two->path)) {
174 if (should_break(p->one, p->two,
173 - break_score, &score) &&
174 - MINIMUM_BREAK_SIZE <= p->one->size) {
175 + break_score, &score)) {
176 /* Split this into delete and create */
177 struct diff_filespec *null_one, *null_two;
178 struct diff_filepair *dp;