]> git.ipfire.org Git - thirdparty/git.git/commit - merge-ort.c
merge-ort: reuse path strings in pool_alloc_filespec
authorElijah Newren <newren@gmail.com>
Fri, 30 Jul 2021 11:47:43 +0000 (11:47 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Jul 2021 16:01:19 +0000 (09:01 -0700)
commit092e5115d1312c0b30348404d3f5b2bb02909342
tree8e455e4609b8c9d9fa8221883000839c5614c6a4
parentf239fff4c183b231134115bc3b38b4f8e3982d3e
merge-ort: reuse path strings in pool_alloc_filespec

pool_alloc_filespec() was written so that the code when pool != NULL
mimicked the code from alloc_filespec(), which including allocating
enough extra space for the path and then copying it.  However, the path
passed to pool_alloc_filespec() is always going to already be in the
same memory pool, so we may as well reuse it instead of copying it.

For the testcases mentioned in commit 557ac0350d ("merge-ort: begin
performance work; instrument with trace2_region_* calls", 2020-10-28),
this change improves the performance as follows:

                            Before                  After
    no-renames:       198.5 ms ±  3.4 ms     198.3 ms ±  2.9 ms
    mega-renames:     679.1 ms ±  5.6 ms     661.8 ms ±  5.9 ms
    just-one-mega:    271.9 ms ±  2.8 ms     264.6 ms ±  2.5 ms

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-ort.c