Skip to content

Commit 9b25949

Browse files
bjornggitster
authored andcommitted
apply: Don't unnecessarily update line lengths in the preimage
In match_fragment(), the line lengths in the preimage are updated just before calling update_pre_post_images(). That is not necessary, since update_pre_post_images() itself will update the line lengths based on the buffer passed to it. Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e923eae commit 9b25949

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

builtin-apply.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,20 +1905,15 @@ static int match_fragment(struct image *img,
19051905
}
19061906

19071907
/*
1908-
* Ok, the preimage matches with whitespace fuzz. Update it and
1909-
* the common postimage lines to use the same whitespace as the
1910-
* target. imgoff now holds the true length of the target that
1911-
* matches the preimage, and we need to update the line lengths
1912-
* of the preimage to match the target ones.
1908+
* Ok, the preimage matches with whitespace fuzz.
1909+
*
1910+
* imgoff now holds the true length of the target that
1911+
* matches the preimage. Update the preimage and
1912+
* the common postimage context lines to use the same
1913+
* whitespace as the target.
19131914
*/
19141915
fixed_buf = xmalloc(imgoff);
19151916
memcpy(fixed_buf, img->buf + try, imgoff);
1916-
for (i = 0; i < preimage->nr; i++)
1917-
preimage->line[i].len = img->line[try_lno+i].len;
1918-
1919-
/*
1920-
* Update the preimage buffer and the postimage context lines.
1921-
*/
19221917
update_pre_post_images(preimage, postimage,
19231918
fixed_buf, imgoff, postlen);
19241919
return 1;

0 commit comments

Comments
 (0)