From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/4] hval: use File::Spec::Functions::abs2rel
Date: Tue, 12 Nov 2024 20:34:32 +0000 [thread overview]
Message-ID: <20241112203433.2515907-4-e@80x24.org> (raw)
In-Reply-To: <20241112203433.2515907-1-e@80x24.org>
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;
}
next prev parent reply other threads:[~2024-11-12 20:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 20:34 [PATCH 0/4] File::Spec-related things Eric Wong
2024-11-12 20:34 ` [PATCH 1/4] cindex: rework path canonicalization check Eric Wong
2024-11-12 20:34 ` [PATCH 2/4] www_coderepo: drop unused File::Spec import Eric Wong
2024-11-12 20:34 ` Eric Wong [this message]
2024-11-12 20:34 ` [PATCH 4/4] lei_mirror: favor File::Spec::Functions Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241112203433.2515907-4-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).