Skip to content

Commit 0a88f08

Browse files
dakhubgitgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a0f58c5 commit 0a88f08

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

builtin/blame.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,6 @@ struct scoreboard {
255255
int *lineno;
256256
};
257257

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-
267258
static void sanity_check_refcnt(struct scoreboard *);
268259

269260
/*
@@ -276,7 +267,7 @@ static void coalesce(struct scoreboard *sb)
276267
struct blame_entry *ent, *next;
277268

278269
for (ent = sb->ent; ent && (next = ent->next); ent = next) {
279-
if (same_suspect(ent->suspect, next->suspect) &&
270+
if (ent->suspect == next->suspect &&
280271
ent->guilty == next->guilty &&
281272
ent->s_lno + ent->num_lines == next->s_lno) {
282273
ent->num_lines += next->num_lines;
@@ -735,7 +726,7 @@ static int find_last_in_target(struct scoreboard *sb, struct origin *target)
735726
int last_in_target = -1;
736727

737728
for (e = sb->ent; e; e = e->next) {
738-
if (e->guilty || !same_suspect(e->suspect, target))
729+
if (e->guilty || e->suspect != target)
739730
continue;
740731
if (last_in_target < e->s_lno + e->num_lines)
741732
last_in_target = e->s_lno + e->num_lines;
@@ -755,7 +746,7 @@ static void blame_chunk(struct scoreboard *sb,
755746
struct blame_entry *e;
756747

757748
for (e = sb->ent; e; e = e->next) {
758-
if (e->guilty || !same_suspect(e->suspect, target))
749+
if (e->guilty || e->suspect != target)
759750
continue;
760751
if (same <= e->s_lno)
761752
continue;
@@ -985,7 +976,7 @@ static int find_move_in_parent(struct scoreboard *sb,
985976
while (made_progress) {
986977
made_progress = 0;
987978
for (e = sb->ent; e; e = e->next) {
988-
if (e->guilty || !same_suspect(e->suspect, target) ||
979+
if (e->guilty || e->suspect != target ||
989980
ent_score(sb, e) < blame_move_score)
990981
continue;
991982
find_copy_in_blob(sb, e, parent, split, &file_p);
@@ -1020,14 +1011,14 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
10201011

10211012
for (e = sb->ent, num_ents = 0; e; e = e->next)
10221013
if (!e->scanned && !e->guilty &&
1023-
same_suspect(e->suspect, target) &&
1014+
e->suspect == target &&
10241015
min_score < ent_score(sb, e))
10251016
num_ents++;
10261017
if (num_ents) {
10271018
blame_list = xcalloc(num_ents, sizeof(struct blame_list));
10281019
for (e = sb->ent, i = 0; e; e = e->next)
10291020
if (!e->scanned && !e->guilty &&
1030-
same_suspect(e->suspect, target) &&
1021+
e->suspect == target &&
10311022
min_score < ent_score(sb, e))
10321023
blame_list[i++].ent = e;
10331024
}
@@ -1171,7 +1162,7 @@ static void pass_whole_blame(struct scoreboard *sb,
11711162
origin->file.ptr = NULL;
11721163
}
11731164
for (e = sb->ent; e; e = e->next) {
1174-
if (!same_suspect(e->suspect, origin))
1165+
if (e->suspect != origin)
11751166
continue;
11761167
origin_incref(porigin);
11771168
origin_decref(e->suspect);
@@ -1560,7 +1551,7 @@ static void assign_blame(struct scoreboard *sb, int opt)
15601551

15611552
/* Take responsibility for the remaining entries */
15621553
for (ent = sb->ent; ent; ent = ent->next)
1563-
if (same_suspect(ent->suspect, suspect))
1554+
if (ent->suspect == suspect)
15641555
found_guilty_entry(ent);
15651556
origin_decref(suspect);
15661557

0 commit comments

Comments
 (0)