mirror of
https://github.com/git/git.git
synced 2024-10-30 13:57:54 +01:00
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>
This commit is contained in:
parent
a0f58c5830
commit
0a88f08e28
1 changed files with 8 additions and 17 deletions
|
@ -255,15 +255,6 @@ struct scoreboard {
|
||||||
int *lineno;
|
int *lineno;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline int same_suspect(struct origin *a, struct origin *b)
|
|
||||||
{
|
|
||||||
if (a == b)
|
|
||||||
return 1;
|
|
||||||
if (a->commit != b->commit)
|
|
||||||
return 0;
|
|
||||||
return !strcmp(a->path, b->path);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sanity_check_refcnt(struct scoreboard *);
|
static void sanity_check_refcnt(struct scoreboard *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -276,7 +267,7 @@ static void coalesce(struct scoreboard *sb)
|
||||||
struct blame_entry *ent, *next;
|
struct blame_entry *ent, *next;
|
||||||
|
|
||||||
for (ent = sb->ent; ent && (next = ent->next); ent = next) {
|
for (ent = sb->ent; ent && (next = ent->next); ent = next) {
|
||||||
if (same_suspect(ent->suspect, next->suspect) &&
|
if (ent->suspect == next->suspect &&
|
||||||
ent->guilty == next->guilty &&
|
ent->guilty == next->guilty &&
|
||||||
ent->s_lno + ent->num_lines == next->s_lno) {
|
ent->s_lno + ent->num_lines == next->s_lno) {
|
||||||
ent->num_lines += next->num_lines;
|
ent->num_lines += next->num_lines;
|
||||||
|
@ -735,7 +726,7 @@ static int find_last_in_target(struct scoreboard *sb, struct origin *target)
|
||||||
int last_in_target = -1;
|
int last_in_target = -1;
|
||||||
|
|
||||||
for (e = sb->ent; e; e = e->next) {
|
for (e = sb->ent; e; e = e->next) {
|
||||||
if (e->guilty || !same_suspect(e->suspect, target))
|
if (e->guilty || e->suspect != target)
|
||||||
continue;
|
continue;
|
||||||
if (last_in_target < e->s_lno + e->num_lines)
|
if (last_in_target < e->s_lno + e->num_lines)
|
||||||
last_in_target = e->s_lno + e->num_lines;
|
last_in_target = e->s_lno + e->num_lines;
|
||||||
|
@ -755,7 +746,7 @@ static void blame_chunk(struct scoreboard *sb,
|
||||||
struct blame_entry *e;
|
struct blame_entry *e;
|
||||||
|
|
||||||
for (e = sb->ent; e; e = e->next) {
|
for (e = sb->ent; e; e = e->next) {
|
||||||
if (e->guilty || !same_suspect(e->suspect, target))
|
if (e->guilty || e->suspect != target)
|
||||||
continue;
|
continue;
|
||||||
if (same <= e->s_lno)
|
if (same <= e->s_lno)
|
||||||
continue;
|
continue;
|
||||||
|
@ -985,7 +976,7 @@ static int find_move_in_parent(struct scoreboard *sb,
|
||||||
while (made_progress) {
|
while (made_progress) {
|
||||||
made_progress = 0;
|
made_progress = 0;
|
||||||
for (e = sb->ent; e; e = e->next) {
|
for (e = sb->ent; e; e = e->next) {
|
||||||
if (e->guilty || !same_suspect(e->suspect, target) ||
|
if (e->guilty || e->suspect != target ||
|
||||||
ent_score(sb, e) < blame_move_score)
|
ent_score(sb, e) < blame_move_score)
|
||||||
continue;
|
continue;
|
||||||
find_copy_in_blob(sb, e, parent, split, &file_p);
|
find_copy_in_blob(sb, e, parent, split, &file_p);
|
||||||
|
@ -1020,14 +1011,14 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
|
||||||
|
|
||||||
for (e = sb->ent, num_ents = 0; e; e = e->next)
|
for (e = sb->ent, num_ents = 0; e; e = e->next)
|
||||||
if (!e->scanned && !e->guilty &&
|
if (!e->scanned && !e->guilty &&
|
||||||
same_suspect(e->suspect, target) &&
|
e->suspect == target &&
|
||||||
min_score < ent_score(sb, e))
|
min_score < ent_score(sb, e))
|
||||||
num_ents++;
|
num_ents++;
|
||||||
if (num_ents) {
|
if (num_ents) {
|
||||||
blame_list = xcalloc(num_ents, sizeof(struct blame_list));
|
blame_list = xcalloc(num_ents, sizeof(struct blame_list));
|
||||||
for (e = sb->ent, i = 0; e; e = e->next)
|
for (e = sb->ent, i = 0; e; e = e->next)
|
||||||
if (!e->scanned && !e->guilty &&
|
if (!e->scanned && !e->guilty &&
|
||||||
same_suspect(e->suspect, target) &&
|
e->suspect == target &&
|
||||||
min_score < ent_score(sb, e))
|
min_score < ent_score(sb, e))
|
||||||
blame_list[i++].ent = e;
|
blame_list[i++].ent = e;
|
||||||
}
|
}
|
||||||
|
@ -1171,7 +1162,7 @@ static void pass_whole_blame(struct scoreboard *sb,
|
||||||
origin->file.ptr = NULL;
|
origin->file.ptr = NULL;
|
||||||
}
|
}
|
||||||
for (e = sb->ent; e; e = e->next) {
|
for (e = sb->ent; e; e = e->next) {
|
||||||
if (!same_suspect(e->suspect, origin))
|
if (e->suspect != origin)
|
||||||
continue;
|
continue;
|
||||||
origin_incref(porigin);
|
origin_incref(porigin);
|
||||||
origin_decref(e->suspect);
|
origin_decref(e->suspect);
|
||||||
|
@ -1560,7 +1551,7 @@ static void assign_blame(struct scoreboard *sb, int opt)
|
||||||
|
|
||||||
/* Take responsibility for the remaining entries */
|
/* Take responsibility for the remaining entries */
|
||||||
for (ent = sb->ent; ent; ent = ent->next)
|
for (ent = sb->ent; ent; ent = ent->next)
|
||||||
if (same_suspect(ent->suspect, suspect))
|
if (ent->suspect == suspect)
|
||||||
found_guilty_entry(ent);
|
found_guilty_entry(ent);
|
||||||
origin_decref(suspect);
|
origin_decref(suspect);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue