diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-05-28 11:23:52 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-05-28 18:38:07 +0900 |
commit | 17530b2ed2eac62706b8bbbcf93f62866f651ffd (patch) | |
tree | c64f00c1321765a53b58101ee50e4cd4ce443dd8 /t/t4126-apply-empty.sh | |
parent | send-email: move trivial config handling to Perl (diff) | |
download | tgif-17530b2ed2eac62706b8bbbcf93f62866f651ffd.tar.xz |
perl: nano-optimize by replacing Cwd::cwd() with Cwd::getcwd()
It has been pointed out[1] that cwd() invokes "pwd(1)" while getcwd()
is a Perl-native XS function. For what we're using these for we can
use getcwd().
The performance difference is miniscule, we're saving on the order of
a millisecond or so, see [2] below for the benchmark. I don't think
this matters in practice for optimizing git-send-email or perl
execution (unlike the patches leading up to this one).
But let's do it regardless of that, if only so we don't have to think
about this as a low-hanging fruit anymore.
1. https://lore.kernel.org/git/20210512180517.GA11354@dcvr/
2.
$ perl -MBenchmark=:all -MCwd -wE 'cmpthese(10000, { getcwd => sub { getcwd }, cwd => sub { cwd }, pwd => sub { system "pwd >/dev/null" }})'
(warning: too few iterations for a reliable count)
Rate pwd cwd getcwd
pwd 982/s -- -48% -100%
cwd 1890/s 92% -- -100%
getcwd 10000000000000000000/s 1018000000000000000% 529000000000000064% -
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4126-apply-empty.sh')
0 files changed, 0 insertions, 0 deletions