{"thread":{"id":"22927","subject":"[PATCH v4 1/5] apply: Don't unnecessarily update line lengths in the preimage","startedAt":"2010-03-06T14:30:21Z","lastAt":"2010-03-06T14:30:21Z","messageCount":1,"participants":["Björn Gustavsson"],"isPatch":true,"patchVersion":4,"patchTotal":5},"messages":[{"id":"136238","messageId":"4B9266FD.1060103@gmail.com","threadId":"22927","inReplyTo":null,"subject":"[PATCH v4 1/5] apply: Don't unnecessarily update line lengths in the preimage","fromName":"Björn Gustavsson","fromEmail":"bgustavsson@gmail.com","sentAt":"2010-03-06T14:30:21Z","receivedAt":"2010-03-06T14:30:21Z","isPatch":true,"sender":{"key":"bgustavsson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/74840?v=4"},"body":"In match_fragment(), the line lengths in the preimage are updated\njust before calling update_pre_post_images(). That is not\nnecessary, since update_pre_post_images() itself will\nupdate the line lengths based on the buffer passed to it.\n\nSigned-off-by: Björn Gustavsson <bgustavsson@gmail.com>\n---\n builtin-apply.c |   17 ++++++-----------\n 1 files changed, 6 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin-apply.c b/builtin-apply.c\nindex 2a1004d..fc6c708 100644\n--- a/builtin-apply.c\n+++ b/builtin-apply.c\n@@ -1905,20 +1905,15 @@ static int match_fragment(struct image *img,\n \t\t}\n \n \t\t/*\n-\t\t * Ok, the preimage matches with whitespace fuzz. Update it and\n-\t\t * the common postimage lines to use the same whitespace as the\n-\t\t * target. imgoff now holds the true length of the target that\n-\t\t * matches the preimage, and we need to update the line lengths\n-\t\t * of the preimage to match the target ones.\n+\t\t * Ok, the preimage matches with whitespace fuzz.\n+\t\t *\n+\t\t * imgoff now holds the true length of the target that\n+\t\t * matches the preimage.  Update the preimage and\n+\t\t * the common postimage context lines to use the same\n+\t\t * whitespace as the target.\n \t\t */\n \t\tfixed_buf = xmalloc(imgoff);\n \t\tmemcpy(fixed_buf, img->buf + try, imgoff);\n-\t\tfor (i = 0; i < preimage->nr; i++)\n-\t\t\tpreimage->line[i].len = img->line[try_lno+i].len;\n-\n-\t\t/*\n-\t\t * Update the preimage buffer and the postimage context lines.\n-\t\t */\n \t\tupdate_pre_post_images(preimage, postimage,\n \t\t\t\tfixed_buf, imgoff, postlen);\n \t\treturn 1;\n-- \n1.7.0\n"}]}