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 8230A1F8E0 for ; Fri, 17 Jul 2020 06:31:56 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 6/8] overidx: favor non-OO sub dispatch for internal subs Date: Fri, 17 Jul 2020 06:31:53 +0000 Message-Id: <20200717063155.3734-7-e@yhbt.net> In-Reply-To: <20200717063155.3734-1-e@yhbt.net> References: <20200717063155.3734-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: OO method dispatch was 10-15% slower when I was implementing the NNTP server. It also serves as a helpful reminder to the reader at the callsite as to whether a sub is likely in the same package as the caller or not. --- lib/PublicInbox/OverIdx.pm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm index 52f6328e..29c6e0b9 100644 --- a/lib/PublicInbox/OverIdx.pm +++ b/lib/PublicInbox/OverIdx.pm @@ -180,10 +180,10 @@ sub resolve_mid_to_tid { sub create_ghost { my ($self, $mid) = @_; - my $id = $self->mid2id($mid); - my $num = $self->next_ghost_num; + my $id = mid2id($self, $mid); + my $num = next_ghost_num($self); $num < 0 or die "ghost num is non-negative: $num\n"; - my $tid = $self->next_tid; + my $tid = next_tid($self); my $dbh = $self->{dbh}; $dbh->prepare_cached(<<'')->execute($num, $tid); INSERT INTO over (num, tid) VALUES (?,?) @@ -221,7 +221,7 @@ sub link_refs { merge_threads($self, $tid, $ptid); } } else { - $tid = defined $old_tid ? $old_tid : $self->next_tid; + $tid = defined $old_tid ? $old_tid : next_tid($self); } $tid; } @@ -283,7 +283,7 @@ sub _add_over { merge_threads($self, $$old_tid, $cur_tid); } elsif ($n < 0) { # ghost link_refs($self, $refs, $$old_tid); - $self->delete_by_num($n); + delete_by_num($self, $n); $$v++; } 1; @@ -295,8 +295,8 @@ sub add_over { my $old_tid; my $vivified = 0; - $self->begin_lazy; - $self->delete_by_num($num, \$old_tid); + begin_lazy($self); + delete_by_num($self, $num, \$old_tid); foreach my $mid (@$mids) { my $v = 0; each_by_mid($self, $mid, ['tid'], \&_add_over, @@ -305,7 +305,7 @@ sub add_over { $vivified += $v; } my $tid = $vivified ? $old_tid : link_refs($self, $refs, $old_tid); - my $sid = $self->sid($xpath); + my $sid = sid($self, $xpath); my $dbh = $self->{dbh}; my $sth = $dbh->prepare_cached(<<''); INSERT INTO over (num, tid, sid, ts, ds, ddd) @@ -320,7 +320,7 @@ VALUES (?,?,?,?,?,?) INSERT INTO id2num (id, num) VALUES (?,?) foreach my $mid (@$mids) { - my $id = $self->mid2id($mid); + my $id = mid2id($self, $mid); $sth->execute($id, $num); } } @@ -328,7 +328,7 @@ INSERT INTO id2num (id, num) VALUES (?,?) sub _remove_oid { my ($self, $smsg, $oid, $nr) = @_; if (!defined($oid) || $smsg->{blob} eq $oid) { - $self->delete_by_num($smsg->{num}); + delete_by_num($self, $smsg->{num}); $$nr++; } 1; @@ -339,7 +339,7 @@ sub _remove_oid { sub remove_oid { my ($self, $oid, $mid) = @_; my $nr = 0; - $self->begin_lazy; + begin_lazy($self); each_by_mid($self, $mid, ['ddd'], \&_remove_oid, $oid, \$nr); $nr; } @@ -355,7 +355,7 @@ sub _num_mid0_for_oid { sub num_mid0_for_oid { my ($self, $oid, $mid) = @_; my $res = []; - $self->begin_lazy; + begin_lazy($self); each_by_mid($self, $mid, ['ddd'], \&_num_mid0_for_oid, $oid, $res); @$res, # ($num, $mid0); }