From d11feea98718f2abb109af4216a36bdbd21b7191 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 11 Sep 2020 07:32:31 +0000 Subject: treewide: avoid `goto &NAME' for tail recursion While Perl implements tail recursion via `goto' which allows avoiding warnings on deep recursion. It doesn't (as of 5.28) optimize the speed of such dispatches, though it may reduce ephemeral memory usage. Make the code less alien to hackers coming from other languages by using normal subroutine dispatch. It's actually slightly faster in micro benchmarks due to the complexity of `goto &NAME'. --- lib/PublicInbox/DS.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/DS.pm') diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 661be1fd..9c278307 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -244,7 +244,7 @@ sub reap_pids { } # reentrant SIGCHLD handler (since reap_pids is not reentrant) -sub enqueue_reap { $reap_armed //= requeue(\&reap_pids) } +sub enqueue_reap () { $reap_armed //= requeue(\&reap_pids) } sub in_loop () { $in_loop } @@ -629,7 +629,7 @@ sub dwaitpid ($$$) { push @$wait_pids, [ @_ ]; # [ $pid, $cb, $arg ] # We could've just missed our SIGCHLD, cover it, here: - goto &enqueue_reap; # tail recursion + enqueue_reap(); } sub _run_later () { -- cgit v1.2.3-24-ge0c7