]> Sergey Matveev's repositories - public-inbox.git/commitdiff
git_async_cat: inline + drop redundant batch_prepare call
authorEric Wong <e@80x24.org>
Thu, 17 Sep 2020 08:57:51 +0000 (08:57 +0000)
committerEric Wong <e@80x24.org>
Fri, 18 Sep 2020 01:21:15 +0000 (01:21 +0000)
$git->cat_async already calls $git->batch_prepare iff needed, so
we can reduce subroutine calls and inline a one-off subroutine
to save some memory, here.

lib/PublicInbox/GitAsyncCat.pm

index 5f785df72ae4fb387a3ddb8aa28464adc4d65bbb..db1a7f9467e83816ab947e977c5d2782c01b4b96 100644 (file)
@@ -14,14 +14,6 @@ use parent qw(PublicInbox::DS Exporter);
 use PublicInbox::Syscall qw(EPOLLIN EPOLLET);
 our @EXPORT = qw(git_async_cat);
 
-sub _add {
-       my ($class, $git) = @_;
-       $git->batch_prepare;
-       my $self = bless { git => $git }, $class;
-       $self->SUPER::new($git->{in}, EPOLLIN|EPOLLET);
-       \undef; # this is a true ref()
-}
-
 sub event_step {
        my ($self) = @_;
        my $git = $self->{git};
@@ -36,7 +28,11 @@ sub event_step {
 sub git_async_cat ($$$$) {
        my ($git, $oid, $cb, $arg) = @_;
        $git->cat_async($oid, $cb, $arg);
-       $git->{async_cat} //= _add(__PACKAGE__, $git);
+       $git->{async_cat} //= do {
+               my $self = bless { git => $git }, __PACKAGE__;
+               $self->SUPER::new($git->{in}, EPOLLIN|EPOLLET);
+               \undef; # this is a true ref()
+       };
 }
 
 1;