about summary refs log tree commit homepage
path: root/lib/PublicInbox/Eml.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/Eml.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/Eml.pm')
-rw-r--r--lib/PublicInbox/Eml.pm2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/PublicInbox/Eml.pm b/lib/PublicInbox/Eml.pm
index 1fecd41b..571edc5c 100644
--- a/lib/PublicInbox/Eml.pm
+++ b/lib/PublicInbox/Eml.pm
@@ -129,7 +129,7 @@ sub new {
 sub new_sub {
         my (undef, $ref) = @_;
         # special case for messages like <85k5su9k59.fsf_-_@lola.goethe.zz>
-        $$ref =~ /\A(\r?\n)/s or goto &new;
+        $$ref =~ /\A(\r?\n)/s or return new(undef, $ref);
         my $hdr = substr($$ref, 0, $+[0], ''); # sv_chop on $$ref
         bless { hdr => \$hdr, crlf => $1, bdy => $ref }, __PACKAGE__;
 }