]> Sergey Matveev's repositories - public-inbox.git/commitdiff
ds: next_tick: avoid $_ in top-level loop iterator
authorEric Wong <e@80x24.org>
Mon, 1 Feb 2021 08:28:31 +0000 (22:28 -1000)
committerEric Wong <e@80x24.org>
Mon, 1 Feb 2021 11:38:26 +0000 (11:38 +0000)
$_ at the top of a potentially deep stack below may cause
surprising behavior as I experienced with ExtSearchIdx.  In the
future, we'll limit our $_ usage to easily-auditable bits (e.g.
map, grep, and small for loops)

lib/PublicInbox/DS.pm

index 2d312f0ac15084fe6b295351748d481a013d8ac9..263c34580afdb4a4d73316e6a37c6353acbb8352 100644 (file)
@@ -162,13 +162,13 @@ sub now () { clock_gettime(CLOCK_MONOTONIC) }
 sub next_tick () {
     my $q = $nextq or return;
     $nextq = undef;
-    for (@$q) {
+    for my $obj (@$q) {
         # we avoid "ref" on blessed refs to workaround a Perl 5.16.3 leak:
         # https://rt.perl.org/Public/Bug/Display.html?id=114340
-        if (blessed($_)) {
-            $_->event_step;
+        if (blessed($obj)) {
+            $obj->event_step;
         } else {
-            $_->();
+            $obj->();
         }
     }
 }