Skip to content

Commit

Permalink
blame: drop blob data after passing blame to the parent
Browse files Browse the repository at this point in the history
We used to keep the blob data for each origin that has any remaining
line in the result, but this will get very costly with a huge file that
has a deep history.  This patch releases the blob after we ran diff
between the child rev and its parents.  When passing blame from a parent
to its parent (i.e. the grandparent), the blob data for the parent may
need to be read again, but it should be relatively cheap, thanks to
delta-base cache.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Dec 12, 2007
1 parent ef4cffd commit 7c3c796
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions builtin-blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ static void origin_decref(struct origin *o)
}
}

static void drop_origin_blob(struct origin *o)
{
if (o->file.ptr) {
free(o->file.ptr);
o->file.ptr = NULL;
}
}

/*
* Each group of lines is described by a blame_entry; it can be split
* as we pass blame to the parents. They form a linked list in the
Expand Down Expand Up @@ -1274,8 +1282,13 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
}

finish:
for (i = 0; i < MAXPARENT; i++)
origin_decref(parent_origin[i]);
for (i = 0; i < MAXPARENT; i++) {
if (parent_origin[i]) {
drop_origin_blob(parent_origin[i]);
origin_decref(parent_origin[i]);
}
}
drop_origin_blob(origin);
}

/*
Expand Down

0 comments on commit 7c3c796

Please sign in to comment.