Skip to content

Commit f4f19fb

Browse files
peffgitster
authored andcommitted
diffcore-break: free filespec data as we go
As we look at each changed file and consider breaking it, we load the blob data and make a decision about whether to break, which is independent of any other blobs that might have changed. However, we keep the data in memory while we consider breaking all of the other files. Which means that both versions of every file you are diffing are in memory at the same time. This patch instead frees the blob data as we finish with each file pair, leading to much lower memory usage. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 78d553b commit f4f19fb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

diffcore-break.c

+4
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,16 @@ void diffcore_break(int break_score)
204204
dp->score = score;
205205
dp->broken_pair = 1;
206206

207+
diff_free_filespec_data(p->one);
208+
diff_free_filespec_data(p->two);
207209
free(p); /* not diff_free_filepair(), we are
208210
* reusing one and two here.
209211
*/
210212
continue;
211213
}
212214
}
215+
diff_free_filespec_data(p->one);
216+
diff_free_filespec_data(p->two);
213217
diff_q(&outq, p);
214218
}
215219
free(q->queue);

0 commit comments

Comments
 (0)