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-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,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 5D2721FA09 for ; Sat, 18 Apr 2020 03:38:54 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/8] inbox: replace `eval {}' with `do {}' where appropriate Date: Sat, 18 Apr 2020 03:38:49 +0000 Message-Id: <20200418033853.9798-5-e@yhbt.net> In-Reply-To: <20200418033853.9798-1-e@yhbt.net> References: <20200418033853.9798-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: -Git->new and -Limiter->new will never fail unless there's an OOM, so using `eval' is incorrect. --- lib/PublicInbox/Inbox.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index e49f85fc..4bd82989 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -82,7 +82,7 @@ sub _set_uint ($$$) { sub _set_limiter ($$$) { my ($self, $pi_config, $pfx) = @_; my $lkey = "-${pfx}_limiter"; - $self->{$lkey} ||= eval { + $self->{$lkey} ||= do { # full key is: publicinbox.$NAME.httpbackendmax my $mkey = $pfx.'max'; my $val = $self->{$mkey} or return; @@ -130,7 +130,7 @@ sub version { $_[0]->{version} // 1 } sub git_epoch { my ($self, $epoch) = @_; $self->version == 2 or return; - $self->{"$epoch.git"} ||= eval { + $self->{"$epoch.git"} ||= do { my $git_dir = "$self->{inboxdir}/git/$epoch.git"; my $g = PublicInbox::Git->new($git_dir); $g->{-httpbackend_limiter} = $self->{-httpbackend_limiter}; @@ -141,7 +141,7 @@ sub git_epoch { sub git { my ($self) = @_; - $self->{git} ||= eval { + $self->{git} ||= do { my $git_dir = $self->{inboxdir}; $git_dir .= '/all.git' if $self->version == 2; my $g = PublicInbox::Git->new($git_dir);