{"thread":{"id":"35936","subject":"[PATCH] builtin/blame.c::find_copy_in_blob: no need to scan for region end","startedAt":"2014-02-22T16:02:47Z","lastAt":"2014-02-25T17:51:45Z","messageCount":2,"participants":["David Kastrup","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"235191","messageId":"1393084967-23408-1-git-send-email-dak@gnu.org","threadId":"35936","inReplyTo":null,"subject":"[PATCH] builtin/blame.c::find_copy_in_blob: no need to scan for region end","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2014-02-22T16:02:47Z","receivedAt":"2014-02-22T16:02:47Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"The region end can be looked up just like its beginning.\n\nSigned-off-by: David Kastrup <dak@gnu.org>\n---\n builtin/blame.c | 9 +--------\n 1 file changed, 1 insertion(+), 8 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex e44a6bb..96716dd 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -939,7 +939,6 @@ static void find_copy_in_blob(struct scoreboard *sb,\n \t\t\t      mmfile_t *file_p)\n {\n \tconst char *cp;\n-\tint cnt;\n \tmmfile_t file_o;\n \tstruct handle_split_cb_data d;\n \n@@ -950,13 +949,7 @@ static void find_copy_in_blob(struct scoreboard *sb,\n \t */\n \tcp = nth_line(sb, ent->lno);\n \tfile_o.ptr = (char *) cp;\n-\tcnt = ent->num_lines;\n-\n-\twhile (cnt && cp < sb->final_buf + sb->final_buf_size) {\n-\t\tif (*cp++ == '\\n')\n-\t\t\tcnt--;\n-\t}\n-\tfile_o.size = cp - file_o.ptr;\n+\tfile_o.size = nth_line(sb, ent->lno + ent->num_lines) - cp;\n \n \t/*\n \t * file_o is a part of final image we are annotating.\n-- \n1.8.3.2\n"},{"id":"235329","messageId":"xmqq61o36pxq.fsf@gitster.dls.corp.google.com","threadId":"35936","inReplyTo":"1393084967-23408-1-git-send-email-dak@gnu.org","subject":"Re: [PATCH] builtin/blame.c::find_copy_in_blob: no need to scan for region end","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-25T17:51:45Z","receivedAt":"2014-02-25T17:51:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Kastrup <dak@gnu.org> writes:\n\n> The region end can be looked up just like its beginning.\n>\n> Signed-off-by: David Kastrup <dak@gnu.org>\n> ---\n>  builtin/blame.c | 9 +--------\n>  1 file changed, 1 insertion(+), 8 deletions(-)\n\nYay, code reduction!  Thanks.\n\n> diff --git a/builtin/blame.c b/builtin/blame.c\n> index e44a6bb..96716dd 100644\n> --- a/builtin/blame.c\n> +++ b/builtin/blame.c\n> @@ -939,7 +939,6 @@ static void find_copy_in_blob(struct scoreboard *sb,\n>  \t\t\t      mmfile_t *file_p)\n>  {\n>  \tconst char *cp;\n> -\tint cnt;\n>  \tmmfile_t file_o;\n>  \tstruct handle_split_cb_data d;\n>  \n> @@ -950,13 +949,7 @@ static void find_copy_in_blob(struct scoreboard *sb,\n>  \t */\n>  \tcp = nth_line(sb, ent->lno);\n>  \tfile_o.ptr = (char *) cp;\n> -\tcnt = ent->num_lines;\n> -\n> -\twhile (cnt && cp < sb->final_buf + sb->final_buf_size) {\n> -\t\tif (*cp++ == '\\n')\n> -\t\t\tcnt--;\n> -\t}\n> -\tfile_o.size = cp - file_o.ptr;\n> +\tfile_o.size = nth_line(sb, ent->lno + ent->num_lines) - cp;\n>  \n>  \t/*\n>  \t * file_o is a part of final image we are annotating.\n"}]}