about summary refs log tree commit homepage
path: root/lib/PublicInbox/GitAsyncCat.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-09-19 09:37:13 +0000
committerEric Wong <e@80x24.org>2020-09-19 21:39:46 +0000
commit881a5493a8c970c10c051cc55d10d2968e71e691 (patch)
tree2ad0e7a2658ae855b4c1a5bae663633dfca01098 /lib/PublicInbox/GitAsyncCat.pm
parent3750b2e2952e55fe4a04c73fc78f25c5e07d0525 (diff)
downloadpublic-inbox-881a5493a8c970c10c051cc55d10d2968e71e691.tar.gz
This amortizes the cost of recreating PublicInbox::Gcf2 objects
when alternates change in v2 all.git.
Diffstat (limited to 'lib/PublicInbox/GitAsyncCat.pm')
-rw-r--r--lib/PublicInbox/GitAsyncCat.pm24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/PublicInbox/GitAsyncCat.pm b/lib/PublicInbox/GitAsyncCat.pm
index db1a7f94..8a54c608 100644
--- a/lib/PublicInbox/GitAsyncCat.pm
+++ b/lib/PublicInbox/GitAsyncCat.pm
@@ -16,21 +16,27 @@ our @EXPORT = qw(git_async_cat);
 
 sub event_step {
         my ($self) = @_;
-        my $git = $self->{git};
-        return $self->close if ($git->{in} // 0) != ($self->{sock} // 1);
-        my $inflight = $git->{inflight};
+        my $gitish = $self->{gitish};
+        return $self->close if ($gitish->{in} // 0) != ($self->{sock} // 1);
+        my $inflight = $gitish->{inflight};
         if ($inflight && @$inflight) {
-                $git->cat_async_step($inflight);
-                $self->requeue if @$inflight || exists $git->{cat_rbuf};
+                $gitish->cat_async_step($inflight);
+                $self->requeue if @$inflight || exists $gitish->{cat_rbuf};
         }
 }
 
 sub git_async_cat ($$$$) {
         my ($git, $oid, $cb, $arg) = @_;
-        $git->cat_async($oid, $cb, $arg);
-        $git->{async_cat} //= do {
-                my $self = bless { git => $git }, __PACKAGE__;
-                $self->SUPER::new($git->{in}, EPOLLIN|EPOLLET);
+        my $gitish = $git->{gcf2c}; # PublicInbox::Gcf2Client
+        if ($gitish) {
+                $oid .= " $git->{git_dir}";
+        } else {
+                $gitish = $git;
+        }
+        $gitish->cat_async($oid, $cb, $arg);
+        $gitish->{async_cat} //= do {
+                my $self = bless { gitish => $gitish }, __PACKAGE__;
+                $self->SUPER::new($gitish->{in}, EPOLLIN|EPOLLET);
                 \undef; # this is a true ref()
         };
 }