git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 1/5] apply: Don't unnecessarily update line lengths in the preimage

From
Björn Gustavsson <bgustavsson@gmail.com>
Date
Mar 6, 2010, 14:30 UTC
Message-ID
<4B9266FD.1060103@gmail.com>

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>
---
 builtin-apply.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index 2a1004d..fc6c708 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1905,20 +1905,15 @@ static int match_fragment(struct image *img,
 		}
 
 		/*
-		 * Ok, the preimage matches with whitespace fuzz. Update it and
-		 * the common postimage lines to use the same whitespace as the
-		 * target. imgoff now holds the true length of the target that
-		 * matches the preimage, and we need to update the line lengths
-		 * of the preimage to match the target ones.
+		 * Ok, the preimage matches with whitespace fuzz.
+		 *
+		 * imgoff now holds the true length of the target that
+		 * matches the preimage.  Update the preimage and
+		 * the common postimage context lines to use the same
+		 * whitespace as the target.
 		 */
 		fixed_buf = xmalloc(imgoff);
 		memcpy(fixed_buf, img->buf + try, imgoff);
-		for (i = 0; i < preimage->nr; i++)
-			preimage->line[i].len = img->line[try_lno+i].len;
-
-		/*
-		 * Update the preimage buffer and the postimage context lines.
-		 */
 		update_pre_post_images(preimage, postimage,
 				fixed_buf, imgoff, postlen);
 		return 1;
-- 
1.7.0
Message 1 of 1 in “apply: Don't unnecessarily update line lengths in the preimage”
  1. 1/5 apply: Don't unnecessarily update line lengths in the preimageBjörn Gustavsson, Mar 6, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.