{"thread":{"id":"35705","subject":"[PATCH 0/2] Two mostly janitorial patches for builtin/blame.c","startedAt":"2014-01-22T00:20:13Z","lastAt":"2014-01-22T00:20:15Z","messageCount":3,"participants":["David Kastrup"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"233492","messageId":"1390350015-3040-1-git-send-email-dak@gnu.org","threadId":"35705","inReplyTo":null,"subject":"[PATCH 0/2] Two mostly janitorial patches for builtin/blame.c","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2014-01-22T00:20:13Z","receivedAt":"2014-01-22T00:20:13Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Same series as sent previously, just signed off this time.\n\nDavid Kastrup (2):\n  builtin/blame.c: struct blame_entry does not need a prev link\n  Eliminate same_suspect function in builtin/blame.c\n\n builtin/blame.c | 38 ++++++++++----------------------------\n 1 file changed, 10 insertions(+), 28 deletions(-)\n\n-- \n1.8.3.2\n"},{"id":"233493","messageId":"1390350015-3040-2-git-send-email-dak@gnu.org","threadId":"35705","inReplyTo":"1390350015-3040-1-git-send-email-dak@gnu.org","subject":"[PATCH 1/2] builtin/blame.c: struct blame_entry does not need a prev link","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2014-01-22T00:20:14Z","receivedAt":"2014-01-22T00:20:14Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Signed-off-by: David Kastrup <dak@gnu.org>\n---\n builtin/blame.c | 13 ++-----------\n 1 file changed, 2 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex e44a6bb..2195595 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -197,7 +197,6 @@ static void drop_origin_blob(struct origin *o)\n  * scoreboard structure, sorted by the target line number.\n  */\n struct blame_entry {\n-\tstruct blame_entry *prev;\n \tstruct blame_entry *next;\n \n \t/* the first line of this group in the final image;\n@@ -282,8 +281,6 @@ static void coalesce(struct scoreboard *sb)\n \t\t    ent->s_lno + ent->num_lines == next->s_lno) {\n \t\t\tent->num_lines += next->num_lines;\n \t\t\tent->next = next->next;\n-\t\t\tif (ent->next)\n-\t\t\t\tent->next->prev = ent;\n \t\t\torigin_decref(next->suspect);\n \t\t\tfree(next);\n \t\t\tent->score = 0;\n@@ -534,7 +531,7 @@ static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e)\n \t\tprev = ent;\n \n \t/* prev, if not NULL, is the last one that is below e */\n-\te->prev = prev;\n+\n \tif (prev) {\n \t\te->next = prev->next;\n \t\tprev->next = e;\n@@ -543,8 +540,6 @@ static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e)\n \t\te->next = sb->ent;\n \t\tsb->ent = e;\n \t}\n-\tif (e->next)\n-\t\te->next->prev = e;\n }\n \n /*\n@@ -555,14 +550,12 @@ static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e)\n  */\n static void dup_entry(struct blame_entry *dst, struct blame_entry *src)\n {\n-\tstruct blame_entry *p, *n;\n+\tstruct blame_entry *n;\n \n-\tp = dst->prev;\n \tn = dst->next;\n \torigin_incref(src->suspect);\n \torigin_decref(dst->suspect);\n \tmemcpy(dst, src, sizeof(*src));\n-\tdst->prev = p;\n \tdst->next = n;\n \tdst->score = 0;\n }\n@@ -2502,8 +2495,6 @@ parse_done:\n \t\tent->suspect = o;\n \t\tent->s_lno = bottom;\n \t\tent->next = next;\n-\t\tif (next)\n-\t\t\tnext->prev = ent;\n \t\torigin_incref(o);\n \t}\n \torigin_decref(o);\n-- \n1.8.3.2\n"},{"id":"233494","messageId":"1390350015-3040-3-git-send-email-dak@gnu.org","threadId":"35705","inReplyTo":"1390350015-3040-1-git-send-email-dak@gnu.org","subject":"[PATCH 2/2] Eliminate same_suspect function in builtin/blame.c","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2014-01-22T00:20:15Z","receivedAt":"2014-01-22T00:20:15Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Since the origin pointers are \"interned\" and reference-counted, comparing\nthe pointers rather than the content is enough.  The only uninterned\norigins are cached values kept in commit->util, but same_suspect is not\ncalled on them.\n\nSigned-off-by: David Kastrup <dak@gnu.org>\n---\n builtin/blame.c | 25 ++++++++-----------------\n 1 file changed, 8 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 2195595..ead6148 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -255,15 +255,6 @@ struct scoreboard {\n \tint *lineno;\n };\n \n-static inline int same_suspect(struct origin *a, struct origin *b)\n-{\n-\tif (a == b)\n-\t\treturn 1;\n-\tif (a->commit != b->commit)\n-\t\treturn 0;\n-\treturn !strcmp(a->path, b->path);\n-}\n-\n static void sanity_check_refcnt(struct scoreboard *);\n \n /*\n@@ -276,7 +267,7 @@ static void coalesce(struct scoreboard *sb)\n \tstruct blame_entry *ent, *next;\n \n \tfor (ent = sb->ent; ent && (next = ent->next); ent = next) {\n-\t\tif (same_suspect(ent->suspect, next->suspect) &&\n+\t\tif (ent->suspect == next->suspect &&\n \t\t    ent->guilty == next->guilty &&\n \t\t    ent->s_lno + ent->num_lines == next->s_lno) {\n \t\t\tent->num_lines += next->num_lines;\n@@ -735,7 +726,7 @@ static int find_last_in_target(struct scoreboard *sb, struct origin *target)\n \tint last_in_target = -1;\n \n \tfor (e = sb->ent; e; e = e->next) {\n-\t\tif (e->guilty || !same_suspect(e->suspect, target))\n+\t\tif (e->guilty || e->suspect != target)\n \t\t\tcontinue;\n \t\tif (last_in_target < e->s_lno + e->num_lines)\n \t\t\tlast_in_target = e->s_lno + e->num_lines;\n@@ -755,7 +746,7 @@ static void blame_chunk(struct scoreboard *sb,\n \tstruct blame_entry *e;\n \n \tfor (e = sb->ent; e; e = e->next) {\n-\t\tif (e->guilty || !same_suspect(e->suspect, target))\n+\t\tif (e->guilty || e->suspect != target)\n \t\t\tcontinue;\n \t\tif (same <= e->s_lno)\n \t\t\tcontinue;\n@@ -985,7 +976,7 @@ static int find_move_in_parent(struct scoreboard *sb,\n \twhile (made_progress) {\n \t\tmade_progress = 0;\n \t\tfor (e = sb->ent; e; e = e->next) {\n-\t\t\tif (e->guilty || !same_suspect(e->suspect, target) ||\n+\t\t\tif (e->guilty || e->suspect != target ||\n \t\t\t    ent_score(sb, e) < blame_move_score)\n \t\t\t\tcontinue;\n \t\t\tfind_copy_in_blob(sb, e, parent, split, &file_p);\n@@ -1020,14 +1011,14 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,\n \n \tfor (e = sb->ent, num_ents = 0; e; e = e->next)\n \t\tif (!e->scanned && !e->guilty &&\n-\t\t    same_suspect(e->suspect, target) &&\n+\t\t    e->suspect == target &&\n \t\t    min_score < ent_score(sb, e))\n \t\t\tnum_ents++;\n \tif (num_ents) {\n \t\tblame_list = xcalloc(num_ents, sizeof(struct blame_list));\n \t\tfor (e = sb->ent, i = 0; e; e = e->next)\n \t\t\tif (!e->scanned && !e->guilty &&\n-\t\t\t    same_suspect(e->suspect, target) &&\n+\t\t\t    e->suspect == target &&\n \t\t\t    min_score < ent_score(sb, e))\n \t\t\t\tblame_list[i++].ent = e;\n \t}\n@@ -1171,7 +1162,7 @@ static void pass_whole_blame(struct scoreboard *sb,\n \t\torigin->file.ptr = NULL;\n \t}\n \tfor (e = sb->ent; e; e = e->next) {\n-\t\tif (!same_suspect(e->suspect, origin))\n+\t\tif (e->suspect != origin)\n \t\t\tcontinue;\n \t\torigin_incref(porigin);\n \t\torigin_decref(e->suspect);\n@@ -1560,7 +1551,7 @@ static void assign_blame(struct scoreboard *sb, int opt)\n \n \t\t/* Take responsibility for the remaining entries */\n \t\tfor (ent = sb->ent; ent; ent = ent->next)\n-\t\t\tif (same_suspect(ent->suspect, suspect))\n+\t\t\tif (ent->suspect == suspect)\n \t\t\t\tfound_guilty_entry(ent);\n \t\torigin_decref(suspect);\n \n-- \n1.8.3.2\n"}]}