]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/name-rev.c
name-rev: generate name strings only if they are better
authorRené Scharfe <l.s.r@web.de>
Tue, 4 Feb 2020 21:25:34 +0000 (22:25 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Feb 2020 18:24:15 +0000 (10:24 -0800)
commit977dc1912bd74dbc7f94581f36b7e78eae49a8c3
tree19ffd377274b29ffd0ae529af7ceeac250f9119a
parent1c56fc208400011b196f571041a0bc694fc9637c
name-rev: generate name strings only if they are better

Leave setting the tip_name member of struct rev_name to callers of
create_or_update_name().  This avoids allocations for names that are
rejected by that function.  Here's how this affects the runtime when
working with a fresh clone of Git's own repository; performance numbers
by hyperfine before:

Benchmark #1: ./git -C ../git-pristine/ name-rev --all
  Time (mean ± σ):     437.8 ms ±   4.0 ms    [User: 422.5 ms, System: 15.2 ms]
  Range (min … max):   432.8 ms … 446.3 ms    10 runs

... and with this patch:

Benchmark #1: ./git -C ../git-pristine/ name-rev --all
  Time (mean ± σ):     408.5 ms ±   1.4 ms    [User: 387.2 ms, System: 21.2 ms]
  Range (min … max):   407.1 ms … 411.7 ms    10 runs

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/name-rev.c