From 8e1c3155da4edc082e8e3d8b30351f0c861757a7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 24 Jun 2019 02:52:29 +0000 Subject: ds: pass $self to code references We can reduce the amount of short-lived anonymous subs we create by passing $self to code references. --- lib/PublicInbox/HTTP.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/HTTP.pm') diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index c81aeacd..e132c610 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -247,7 +247,7 @@ sub response_done_cb ($$) { sub { my $env = delete $self->{env}; $self->write(\"0\r\n\r\n") if $alive == 2; - $self->write(sub{$alive ? next_request($self) : $self->close}); + $self->write($alive ? \&next_request : \&close); } } @@ -456,4 +456,11 @@ sub busy () { ($self->{rbuf} ne '' || $self->{env} || $self->{wbuf}); } +# fires after pending writes are complete: +sub restart_pass ($) { + $_[0]->{forward}->restart_read; # see PublicInbox::HTTPD::Async +} + +sub enqueue_restart_pass ($) { $_[0]->write(\&restart_pass) } + 1; -- cgit v1.2.3-24-ge0c7