builtin/blame.c: eliminate same_suspect()

Since the origin pointers are "interned" and reference-counted, comparing the pointers rather than the content is enough. The only uninterned origins are cached values kept in commit->util, but same_suspect is not called on them. Signed-off-by: David Kastrup <dak@gnu.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

David Kastrup committed Jan 22, 2014 at 01:20 UTC 0a88f08e284df1a882771f9e74133e2861b79e2d
1 file changed +8 -17
builtin/blame.c
+8 -17
@@ -255,15 +255,6 @@ struct scoreboard {
255 int *lineno;
256 };
257
258 -static inline int same_suspect(struct origin *a, struct origin *b)
259 -{
260 - if (a == b)
261 - return 1;
262 - if (a->commit != b->commit)
263 - return 0;
264 - return !strcmp(a->path, b->path);
265 -}
266 -
258 static void sanity_check_refcnt(struct scoreboard *);
259
260 /*
@@ -276,7 +267,7 @@ static void coalesce(struct scoreboard *sb)
267 struct blame_entry *ent, *next;
268
269 for (ent = sb->ent; ent && (next = ent->next); ent = next) {
279 - if (same_suspect(ent->suspect, next->suspect) &&
270 + if (ent->suspect == next->suspect &&
271 ent->guilty == next->guilty &&
272 ent->s_lno + ent->num_lines == next->s_lno) {
273 ent->num_lines += next->num_lines;
@@ -735,7 +726,7 @@ static int find_last_in_target(struct scoreboard *sb, struct origin *target)
726 int last_in_target = -1;
727
728 for (e = sb->ent; e; e = e->next) {
738 - if (e->guilty || !same_suspect(e->suspect, target))
729 + if (e->guilty || e->suspect != target)
730 continue;
731 if (last_in_target < e->s_lno + e->num_lines)
732 last_in_target = e->s_lno + e->num_lines;
@@ -755,7 +746,7 @@ static void blame_chunk(struct scoreboard *sb,
746 struct blame_entry *e;
747
748 for (e = sb->ent; e; e = e->next) {
758 - if (e->guilty || !same_suspect(e->suspect, target))
749 + if (e->guilty || e->suspect != target)
750 continue;
751 if (same <= e->s_lno)
752 continue;
@@ -985,7 +976,7 @@ static int find_move_in_parent(struct scoreboard *sb,
976 while (made_progress) {
977 made_progress = 0;
978 for (e = sb->ent; e; e = e->next) {
988 - if (e->guilty || !same_suspect(e->suspect, target) ||
979 + if (e->guilty || e->suspect != target ||
980 ent_score(sb, e) < blame_move_score)
981 continue;
982 find_copy_in_blob(sb, e, parent, split, &file_p);
@@ -1020,14 +1011,14 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
1011
1012 for (e = sb->ent, num_ents = 0; e; e = e->next)
1013 if (!e->scanned && !e->guilty &&
1023 - same_suspect(e->suspect, target) &&
1014 + e->suspect == target &&
1015 min_score < ent_score(sb, e))
1016 num_ents++;
1017 if (num_ents) {
1018 blame_list = xcalloc(num_ents, sizeof(struct blame_list));
1019 for (e = sb->ent, i = 0; e; e = e->next)
1020 if (!e->scanned && !e->guilty &&
1030 - same_suspect(e->suspect, target) &&
1021 + e->suspect == target &&
1022 min_score < ent_score(sb, e))
1023 blame_list[i++].ent = e;
1024 }
@@ -1171,7 +1162,7 @@ static void pass_whole_blame(struct scoreboard *sb,
1162 origin->file.ptr = NULL;
1163 }
1164 for (e = sb->ent; e; e = e->next) {
1174 - if (!same_suspect(e->suspect, origin))
1165 + if (e->suspect != origin)
1166 continue;
1167 origin_incref(porigin);
1168 origin_decref(e->suspect);
@@ -1560,7 +1551,7 @@ static void assign_blame(struct scoreboard *sb, int opt)
1551
1552 /* Take responsibility for the remaining entries */
1553 for (ent = sb->ent; ent; ent = ent->next)
1563 - if (same_suspect(ent->suspect, suspect))
1554 + if (ent->suspect == suspect)
1555 found_guilty_entry(ent);
1556 origin_decref(suspect);
1557