summaryrefslogtreecommitdiff
path: root/xdiff/xinclude.h
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2018-07-19 18:56:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-19 19:46:03 (GMT)
commit64c4e8bccde9d357f6b7adf5277c3157b2bd0d42 (patch)
tree12cd08943ce42690f201807a6ab4d1002cda8471 /xdiff/xinclude.h
parentc671d4b5990f07ca40b0914ca9be65c626608fca (diff)
downloadgit-64c4e8bccde9d357f6b7adf5277c3157b2bd0d42.zip
git-64c4e8bccde9d357f6b7adf5277c3157b2bd0d42.tar.gz
git-64c4e8bccde9d357f6b7adf5277c3157b2bd0d42.tar.bz2
xdiff/xhistogram: move index allocation into find_lcs
This fixes a memory issue when recursing a lot, which can be reproduced as seq 1 100000 >one seq 1 4 100000 >two git diff --no-index --histogram one two Before this patch, histogram_diff would call itself recursively before calling free_index, which would mean a lot of memory is allocated during the recursion and only freed afterwards. By moving the memory allocation (and its free call) into find_lcs, the memory is free'd before we recurse, such that memory is reused in the next step of the recursion instead of using new memory. This addresses only the memory pressure, not the run time complexity, that is also awful for the corner case outlined above. Helpful in understanding the code (in addition to the sparse history of this file), was https://stackoverflow.com/a/32367597 which reproduces most of the code comments of the JGit implementation. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'xdiff/xinclude.h')
0 files changed, 0 insertions, 0 deletions