Skip to content

Commit

Permalink
diffcore-rename: reduce memory footprint by freeing blob data early
Browse files Browse the repository at this point in the history
After running one round of estimate_similarity(), filespecs on either
side will have populated their cnt_data fields, and we do not need
the blob text anymore.  We used to retain the blob data to optimize
for smaller projects (not freeing the blob data here would mean that
the final output phase would not have to re-read it), but we are
efficient enough without such optimization for smaller projects anyway,
and freeing memory early will help larger projects.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
gitster committed Nov 21, 2009
1 parent 8282de9 commit 809809b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions diffcore-rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,13 @@ void diffcore_rename(struct diff_options *options)
this_src.dst = i;
this_src.src = j;
record_if_better(m, &this_src);
/*
* Once we run estimate_similarity,
* We do not need the text anymore.
*/
diff_free_filespec_blob(one);
diff_free_filespec_blob(two);
}
/* We do not need the text anymore */
diff_free_filespec_blob(two);
dst_cnt++;
}

Expand Down

0 comments on commit 809809b

Please sign in to comment.