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,AWL,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 D14801F4CA for ; Tue, 12 Nov 2024 20:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1731443674; bh=zrLmVY60lCE22UNq3lcEjc/AdrYRSPzd9NnPFwBtX08=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Uq9+tKEhdzR43KuOuxdedpdVcbYxZdSnTE87V/FG/2gTDAO1GzOpajb2IP3yePX5W RB4l6k54PmTnS/gWpp7+ebQj4rWSdHew97BSA1hQUTOMbBzMwYeK2CTAhHFf/xghPD XqXgr4c4qS5frvPxTMh5gxL6BStOS8i91o8w/LrY= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/4] hval: use File::Spec::Functions::abs2rel Date: Tue, 12 Nov 2024 20:34:32 +0000 Message-ID: <20241112203433.2515907-4-e@80x24.org> In-Reply-To: <20241112203433.2515907-1-e@80x24.org> References: <20241112203433.2515907-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Function calls are faster than method dispatch and abs2rel() may be called hundreds/thousands of times when listing associated inboxes||coderepos. --- lib/PublicInbox/Hval.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm index 963dbb71..d44b6562 100644 --- a/lib/PublicInbox/Hval.pm +++ b/lib/PublicInbox/Hval.pm @@ -13,7 +13,7 @@ our @EXPORT_OK = qw/ascii_html obfuscate_addrs to_filename src_escape to_attr prurl mid_href fmt_ts ts2str utf8_maybe/; use POSIX qw(strftime); my $enc_ascii = find_encoding('us-ascii'); -use File::Spec; +use File::Spec::Functions qw(abs2rel); # safe-ish acceptable filename pattern for portability our $FN = '[a-zA-Z0-9][a-zA-Z0-9_\-\.]+[a-zA-Z0-9]'; # needs \z anchor @@ -76,7 +76,7 @@ sub prurl ($$) { } elsif ($dslash < 0 && substr($u, 0, 1) ne '/' && substr(my $path = $env->{PATH_INFO}, 0, 1) eq '/') { # this won't touch the FS at all: - File::Spec->abs2rel("/$u", $path); + abs2rel "/$u", $path; } else { $u; }