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>
Björn Gustavsson committed
Mar 6, 2010 at 15:30 UTC
9b25949a07933fb9ce7c10bd309ac176dbe2df2e
1 file changed
+6
-11
builtin-apply.c
+6
-11
@@ -1905,20 +1905,15 @@ static int match_fragment(struct image *img,
1905
}
1906
1907
/*
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.
1914
*/
1915
fixed_buf = xmalloc(imgoff);
1916
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
- */
1917
update_pre_post_images(preimage, postimage,
1918
fixed_buf, imgoff, postlen);
1919
return 1;