Skip to content

Commit 7c3c796

Browse files
committed
blame: drop blob data after passing blame to the parent
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>
1 parent ef4cffd commit 7c3c796

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

builtin-blame.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ static void origin_decref(struct origin *o)
130130
}
131131
}
132132

133+
static void drop_origin_blob(struct origin *o)
134+
{
135+
if (o->file.ptr) {
136+
free(o->file.ptr);
137+
o->file.ptr = NULL;
138+
}
139+
}
140+
133141
/*
134142
* Each group of lines is described by a blame_entry; it can be split
135143
* as we pass blame to the parents. They form a linked list in the
@@ -1274,8 +1282,13 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
12741282
}
12751283

12761284
finish:
1277-
for (i = 0; i < MAXPARENT; i++)
1278-
origin_decref(parent_origin[i]);
1285+
for (i = 0; i < MAXPARENT; i++) {
1286+
if (parent_origin[i]) {
1287+
drop_origin_blob(parent_origin[i]);
1288+
origin_decref(parent_origin[i]);
1289+
}
1290+
}
1291+
drop_origin_blob(origin);
12791292
}
12801293

12811294
/*

0 commit comments

Comments
 (0)