Skip to content

Commit 8282de9

Browse files
peffgitster
authored andcommitted
diffcore-break: save cnt_data for other phases
The "break" phase works by counting changes between two blobs with the same path. We do this by splitting the file into chunks (or lines for text oriented files) and then keeping a count of chunk hashes. The "rename" phase counts changes between blobs at two different paths. However, it uses the exact same set of chunk hashes (which are immutable for a given sha1). The rename phase can therefore use the same hash data as break. Unfortunately, we were throwing this data away after computing it in the break phase. This patch instead attaches it to the filespec and lets it live through the rename phase, working under the assumption that most of the time that breaks are being computed, renames will be too. We only do this optimization for files which have actually been broken, as those ones will be candidates for rename detection (and it is a time-space tradeoff, so we don't want to waste space keeping useless data). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f4f19fb commit 8282de9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

diffcore-break.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static int should_break(struct diff_filespec *src,
6969
return 0; /* we do not break too small filepair */
7070

7171
if (diffcore_count_changes(src, dst,
72-
NULL, NULL,
72+
&src->cnt_data, &dst->cnt_data,
7373
0,
7474
&src_copied, &literal_added))
7575
return 0;
@@ -204,8 +204,8 @@ 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);
207+
diff_free_filespec_blob(p->one);
208+
diff_free_filespec_blob(p->two);
209209
free(p); /* not diff_free_filepair(), we are
210210
* reusing one and two here.
211211
*/

0 commit comments

Comments
 (0)