about summary refs log tree commit homepage
path: root/lib/PublicInbox/ExtMsg.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-09-11 07:32:31 +0000
committerEric Wong <e@80x24.org>2020-09-12 20:29:11 +0000
commitd11feea98718f2abb109af4216a36bdbd21b7191 (patch)
tree1f6f83caf21d52f61524e935fa53dcbb6f789877 /lib/PublicInbox/ExtMsg.pm
parent0a1e15ad863782650a36025b9d52a6e9de5eadf3 (diff)
downloadpublic-inbox-d11feea98718f2abb109af4216a36bdbd21b7191.tar.gz
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'.
Diffstat (limited to 'lib/PublicInbox/ExtMsg.pm')
-rw-r--r--lib/PublicInbox/ExtMsg.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index ce1a47bb..03faf3a1 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -125,12 +125,12 @@ sub ext_msg {
 sub event_step {
         my ($ctx, $sync) = @_;
         # can't find a partial match in current inbox, try the others:
-        my $ibx = shift @{$ctx->{again}} or goto \&finalize_partial;
+        my $ibx = shift @{$ctx->{again}} or return finalize_partial($ctx);
         my $mids = search_partial($ibx, $ctx->{mid}) or
                         return ($sync ? undef : PublicInbox::DS::requeue($ctx));
         $ctx->{n_partial} += scalar(@$mids);
         push @{$ctx->{partial}}, [ $ibx, $mids ];
-        $ctx->{n_partial} >= PARTIAL_MAX ? goto(\&finalize_partial)
+        $ctx->{n_partial} >= PARTIAL_MAX ? finalize_partial($ctx)
                         : ($sync ? undef : PublicInbox::DS::requeue($ctx));
 }
 
@@ -156,7 +156,7 @@ sub finalize_exact {
                 # synchronous fall-through
                 $ctx->event_step while @{$ctx->{again}};
         }
-        goto \&finalize_partial;
+        finalize_partial($ctx);
 }
 
 sub finalize_partial {