From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 6/7] git: speed up ->git_path for non-worktrees
Date: Sun, 26 Nov 2023 14:19:32 +0000 [thread overview]
Message-ID: <20231126141933.593525-6-e@80x24.org> (raw)
In-Reply-To: <20231126141933.593525-1-e@80x24.org>
Only worktrees need to use `git rev-parse --git-path', so avoid
the spawn overhead of a new process. With the SolverGit.pm
limit on coderepo scans disabled and scanning over 800 git repos
for git@vger matches, this reduces up xt/solver.t times by
roughly 25%.
---
lib/PublicInbox/Git.pm | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index fe834210..6c7c11b6 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -99,15 +99,15 @@ sub new {
sub git_path ($$) {
my ($self, $path) = @_;
- $self->{-git_path}->{$path} //= do {
+ $self->{-git_path}->{$path} // do {
+ return "$self->{git_dir}/$path" if -d $self->{git_dir};
+
local $/ = "\n";
- chomp(my $str = $self->qx(qw(rev-parse --git-path), $path));
+ chomp(my $s = $self->qx(qw(rev-parse --git-path), $path));
# git prior to 2.5.0 did not understand --git-path
- if ($str eq "--git-path\n$path") {
- $str = "$self->{git_dir}/$path";
- }
- $str;
+ $self->{-git_path}->{$path} = $s eq "--git-path\n$path" ?
+ "$self->{git_dir}/$path" : $s;
};
}
next prev parent reply other threads:[~2023-11-26 14:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-26 14:19 [PATCH 1/7] WIP-cidx-xh-split Eric Wong
2023-11-26 14:19 ` [PATCH 2/7] WIP-cidx Eric Wong
2023-11-26 14:19 ` [PATCH 3/7] hval: relative paths Eric Wong
2023-11-26 14:19 ` [PATCH 4/7] www_coderepo: load and use cindex join data Eric Wong
2023-11-26 14:19 ` [PATCH 5/7] cindex: require `-g GIT_DIR' or `-r PROJECT_ROOT' Eric Wong
2023-11-26 14:19 ` Eric Wong [this message]
2023-11-26 14:19 ` [PATCH 7/7] cindex: set -cfg_f field unconditionally for --show 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231126141933.593525-6-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.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).