From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C7A021FA35 for ; Tue, 24 Jan 2023 09:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1674553805; bh=5FiYlQgsr0vEKV93dwcbj4RuZrdXV7m9GvyAFoR9bOA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AmDKQ8Xd670idSH8scQauy01Ci6mOOI0ZEgO/sJu5Taz7pWPl7/Cs0CQrUGNP5eTr m+YAIaxNf5l12nHHmF3LeEj0Y2zvkkYdKkqAeJBIyfqH83KAY4hi2DIBK0LYRoa8MG C8MeZV8W8YiSW6QVJfyA1GdEQrqq/am5yBKuV7QU= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 10/11] www_coderepo: remove some needless return statements Date: Tue, 24 Jan 2023 09:49:39 +0000 Message-Id: <20230124094940.572017-11-e@80x24.org> In-Reply-To: <20230124094940.572017-1-e@80x24.org> References: <20230124094940.572017-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Maybe it makes control flow a little easier to rely on implicit return (IIRC, it's slightly faster, too). --- lib/PublicInbox/WwwCoderepo.pm | 37 ++++++++++++---------------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/lib/PublicInbox/WwwCoderepo.pm b/lib/PublicInbox/WwwCoderepo.pm index 024a9d8f..8dcd9772 100644 --- a/lib/PublicInbox/WwwCoderepo.pm +++ b/lib/PublicInbox/WwwCoderepo.pm @@ -220,38 +220,27 @@ sub srv { # endpoint called by PublicInbox::WWW my $git; # handle clone requests my $cr = $self->{pi_cfg}->{-code_repos}; - if ($path_info =~ m!\A/(.+?)/($PublicInbox::GitHTTPBackend::ANY)\z!x) { - $git = $cr->{$1} and return + if ($path_info =~ m!\A/(.+?)/($PublicInbox::GitHTTPBackend::ANY)\z!x and + ($git = $cr->{$1})) { PublicInbox::GitHTTPBackend::serve($ctx->{env},$git,$2); - } - $path_info =~ m!\A/(.+?)/\z! and - ($ctx->{git} = $cr->{$1}) and return summary($self, $ctx); - if ($path_info =~ m!\A/(.+?)/([a-f0-9]+)/s/([^/]+)?\z! and + } elsif ($path_info =~ m!\A/(.+?)/\z! and ($ctx->{git} = $cr->{$1})) { + summary($self, $ctx) + } elsif ($path_info =~ m!\A/(.+?)/([a-f0-9]+)/s/([^/]+)?\z! and ($ctx->{git} = $cr->{$1})) { $ctx->{lh} = $self->{log_fh}; - return PublicInbox::ViewVCS::show($ctx, $2, $3); - } - - if ($path_info =~ m!\A/(.+?)/tree/(.*)\z! and + PublicInbox::ViewVCS::show($ctx, $2, $3); + } elsif ($path_info =~ m!\A/(.+?)/tree/(.*)\z! and ($ctx->{git} = $cr->{$1})) { $ctx->{lh} = $self->{log_fh}; - return PublicInbox::RepoTree::srv_tree($ctx, $2) // r(404); - } - - # snapshots: - if ($path_info =~ m!\A/(.+?)/snapshot/([^/]+)\z! and + PublicInbox::RepoTree::srv_tree($ctx, $2) // r(404); + } elsif ($path_info =~ m!\A/(.+?)/snapshot/([^/]+)\z! and ($ctx->{git} = $cr->{$1})) { $ctx->{wcr} = $self; - return PublicInbox::RepoSnapshot::srv($ctx, $2) // r(404); - } - - if ($path_info =~ m!\A/(.+?)/atom/(.*)\z! and + PublicInbox::RepoSnapshot::srv($ctx, $2) // r(404); + } elsif ($path_info =~ m!\A/(.+?)/atom/(.*)\z! and ($ctx->{git} = $cr->{$1})) { - return PublicInbox::RepoAtom::srv_atom($ctx, $2) // r(404); - } - - # enforce trailing slash: - if ($path_info =~ m!\A/(.+?)\z! and ($git = $cr->{$1})) { + PublicInbox::RepoAtom::srv_atom($ctx, $2) // r(404); + } elsif ($path_info =~ m!\A/(.+?)\z! and ($git = $cr->{$1})) { my $qs = $ctx->{env}->{QUERY_STRING}; my $url = $git->base_url($ctx->{env}); $url .= "?$qs" if $qs ne '';