From 62e3722f13164696a7af66cfa6253f69f0f5892b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 24 Jun 2019 02:52:27 +0000 Subject: ds: favor `delete' over assigning fields to `undef' This is cleaner in most cases and may allow Perl to reuse memory from unused fields. We can do this now that we no longer support Perl 5.8; since Danga::Socket was written with struct-like pseudo-hash support in mind, and Perl 5.9+ dropped support for pseudo-hashes over a decade ago. --- lib/PublicInbox/HTTPD/Async.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/HTTPD/Async.pm') diff --git a/lib/PublicInbox/HTTPD/Async.pm b/lib/PublicInbox/HTTPD/Async.pm index 9cc41f17..bec49337 100644 --- a/lib/PublicInbox/HTTPD/Async.pm +++ b/lib/PublicInbox/HTTPD/Async.pm @@ -63,7 +63,7 @@ sub main_cb ($$$) { # Done! Error handling will happen in $fh->close # called by the {cleanup} handler - $http->{forward} = undef; + delete $http->{forward}; $self->close; } } @@ -81,12 +81,13 @@ sub event_step { $_[0]->{cb}->(@_) } sub close { my $self = shift; - my $cleanup = $self->{cleanup}; - $self->{cleanup} = $self->{cb} = undef; + delete $self->{cb}; $self->SUPER::close(@_); # we defer this to the next timer loop since close is deferred - PublicInbox::EvCleanup::next_tick($cleanup) if $cleanup; + if (my $cleanup = delete $self->{cleanup}) { + PublicInbox::EvCleanup::next_tick($cleanup); + } } 1; -- cgit v1.2.3-24-ge0c7