summaryrefslogtreecommitdiff
path: root/diffcore-rename.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-12-29 20:05:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-04 20:59:34 (GMT)
commit350410f6b13557df71579e2d121c31135ff1cf86 (patch)
treee556ca7f056eee08f9b707e84fd7728bc212e6c5 /diffcore-rename.c
parent9db2ac56168e58f856b001a93ad369affe18879f (diff)
downloadgit-350410f6b13557df71579e2d121c31135ff1cf86.zip
git-350410f6b13557df71579e2d121c31135ff1cf86.tar.gz
git-350410f6b13557df71579e2d121c31135ff1cf86.tar.bz2
diffcore-rename: remove unnecessary duplicate entry checks
Commit 25d5ea410f ("[PATCH] Redo rename/copy detection logic.", 2005-05-24) added a duplicate entry check on rename_src in order to avoid segfaults; the code at the time was prone to double free()s and an easy way to avoid it was just to turn off rename detection for any duplicate entries. Note that the form of the check was modified two commits ago in this series. Similarly, commit 4d6be03b95 ("diffcore-rename: avoid processing duplicate destinations", 2015-02-26) added a duplicate entry check on rename_dst for the exact same reason -- the code was prone to double free()s, and an easy way to avoid it was just to turn off rename detection entirely. Note that the form of the check was modified in the commit just before this one. In the original code in both places, the code was dealing with individual diff_filespecs and trying to match things up, instead of just keeping the original diff_filepairs around as we do now. The intervening change in structure has fixed the accounting problems and the associated double free()s that used to occur, and thus we already have a better fix. As such, we can remove the band-aid checks for duplicate entries. Due to the last two patches, the diffcore_rename() setup is no longer a sizeable chunk of overall runtime. Thus, in a large rebase of many commits with lots of renames and several optimizations to inexact rename detection, this patch only speeds up the overall code by about half a percent or so and is pretty close to the run-to-run variability making it hard to get an exact measurement. However, with some trace2 regions around the setup code in diffcore_rename() so that I can focus on just it, I measure that this patch consistently saves almost a third of the remaining time spent in diffcore_rename() setup. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diffcore-rename.c')
-rw-r--r--diffcore-rename.c23
1 files changed, 0 insertions, 23 deletions
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 2a8fcd5..90db9eb 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -34,18 +34,6 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filepair *p)
*/
static int add_rename_dst(struct diff_filepair *p)
{
- /*
- * If we have multiple entries at the same path in the destination
- * tree (an invalid tree, to be sure), turn off rename detection
- * entirely. Once upon a time, diffcore-rename had double free()
- * issues due to such duplicate paths, resulting in segfaults. See
- * commit 4d6be03b95 ("diffcore-rename: avoid processing duplicate
- * destinations", 2015-02-26).
- */
- if (rename_dst_nr > 0 &&
- !strcmp(rename_dst[rename_dst_nr-1].p->two->path, p->two->path))
- return -1;
-
ALLOC_GROW(rename_dst, rename_dst_nr + 1, rename_dst_alloc);
rename_dst[rename_dst_nr].p = p;
rename_dst[rename_dst_nr].filespec_to_free = NULL;
@@ -63,17 +51,6 @@ static int rename_src_nr, rename_src_alloc;
static void register_rename_src(struct diff_filepair *p)
{
- /*
- * If we have multiple entries at the same path in the source tree
- * (an invalid tree, to be sure), avoid using more more than one
- * such entry in rename detection. Once upon a time, doing so
- * caused segfaults; see commit 25d5ea410f ("[PATCH] Redo
- * rename/copy detection logic.", 2005-05-24).
- */
- if (rename_src_nr > 0 &&
- !strcmp(rename_src[rename_src_nr-1].p->one->path, p->one->path))
- return;
-
if (p->broken_pair) {
if (!break_idx) {
break_idx = xmalloc(sizeof(*break_idx));