]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diffcore-rename: avoid unnecessary strdup'ing in break_idx
authorElijah Newren <newren@gmail.com>
Tue, 8 Jun 2021 16:11:40 +0000 (16:11 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Jun 2021 02:40:04 +0000 (11:40 +0900)
The keys of break_idx are strings from the diff_filepairs of
diff_queued_diff.  break_idx is only used in location_rename_dst(), and
that usage is always before any free'ing of the pairs (and thus the
strings in the pairs).  As such, there is no need to strdup these keys;
we can just reuse the existing strings as-is.

The merge logic doesn't make use of break detection, so this does not
affect the performance of any of my testcases.  It was just a minor
unrelated optimization noted in passing while looking at the code.

Signed-off-by: Elijah Newren <newren@gmail.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diffcore-rename.c

index dfbe65c917e9afecb1a7426994029d5fa5c61110..9c0bc5afb4091353686fb1862421d6bc51846a3f 100644 (file)
@@ -54,7 +54,7 @@ static void register_rename_src(struct diff_filepair *p)
        if (p->broken_pair) {
                if (!break_idx) {
                        break_idx = xmalloc(sizeof(*break_idx));
-                       strintmap_init(break_idx, -1);
+                       strintmap_init_with_options(break_idx, -1, NULL, 0);
                }
                strintmap_set(break_idx, p->one->path, rename_dst_nr);
        }