From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DA04B1F4B4 for ; Thu, 17 Sep 2020 08:57:51 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] git_async_cat: inline + drop redundant batch_prepare call Date: Thu, 17 Sep 2020 08:57:51 +0000 Message-Id: <20200917085751.19983-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: $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 | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/PublicInbox/GitAsyncCat.pm b/lib/PublicInbox/GitAsyncCat.pm index 5f785df7..db1a7f94 100644 --- a/lib/PublicInbox/GitAsyncCat.pm +++ b/lib/PublicInbox/GitAsyncCat.pm @@ -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;