From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8671120086 for ; Mon, 1 Feb 2021 08:28:35 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 19/21] ds: next_tick: avoid $_ in top-level loop iterator Date: Sun, 31 Jan 2021 22:28:31 -1000 Message-Id: <20210201082833.3293-20-e@80x24.org> In-Reply-To: <20210201082833.3293-1-e@80x24.org> References: <20210201082833.3293-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: $_ 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 2d312f0a..263c3458 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -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->(); } } }