about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-01-12 21:17:54 +0000
committerEric Wong <e@yhbt.net>2020-01-13 23:21:29 +0000
commit3874e93d923a3f23816cf307c257120c6941cad2 (patch)
tree3c8ddfbf0390789ae5791f825c6c81cb2393a8dd /lib
parent8fa1fb2bb4409bd1be9526fab182a2e607d5fd10 (diff)
downloadpublic-inbox-3874e93d923a3f23816cf307c257120c6941cad2.tar.gz
No reason to have an empty arrayref lying around when not
everybody needs it.

Re-indent the later-related subs since we're changing a
bunch of lines, anyways.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/DS.pm17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 3c922ccd..673c24eb 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -40,7 +40,7 @@ use Carp qw(confess carp);
 
 my $nextq; # queue for next_tick
 my $wait_pids; # list of [ pid, callback, callback_arg ]
-my $later_queue; # callbacks
+my $later_queue; # list of callbacks to run at some later interval
 my $EXPMAP; # fd -> [ idle_time, $self ]
 our $EXPTIME = 180; # 3 minutes
 my ($later_timer, $reap_timer, $exp_timer);
@@ -71,8 +71,7 @@ Reset all state
 =cut
 sub Reset {
     %DescriptorMap = ();
-    $wait_pids = undef;
-    $later_queue = [];
+    $wait_pids = $later_queue = undef;
     $EXPMAP = {};
     $nextq = $ToClose = $reap_timer = $later_timer = $exp_timer = undef;
     $LoopTimeout = -1;  # no timeout by default
@@ -632,16 +631,14 @@ sub dwaitpid ($$$) {
 }
 
 sub _run_later () {
-    my $run = $later_queue;
-    $later_timer = undef;
-    $later_queue = [];
-    $_->() for @$run;
+        my $run = $later_queue or return;
+        $later_timer = $later_queue = undef;
+        $_->() for @$run;
 }
 
 sub later ($) {
-    my ($cb) = @_;
-    push @$later_queue, $cb;
-    $later_timer //= add_timer(60, \&_run_later);
+        push @$later_queue, $_[0]; # autovivifies @$later_queue
+        $later_timer //= add_timer(60, \&_run_later);
 }
 
 sub expire_old () {