user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 8/8] nntp: cmd_xover: use named sub for long_response
Date: Sat, 21 Dec 2019 08:00:07 +0000	[thread overview]
Message-ID: <20191221080007.27810-9-e@80x24.org> (raw)
In-Reply-To: <20191221080007.27810-1-e@80x24.org>

Introduce xover_i, which does the same thing as the anonymous
sub it replaces.
---
 lib/PublicInbox/NNTP.pm | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index b2927b79..3d3ad539 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -873,6 +873,19 @@ sub cmd_over ($;$) {
 	}
 }
 
+sub xover_i {
+	my ($self, $beg, $end) = @_;
+	my $ng = $self->{ng};
+	my $msgs = $ng->over->query_xover($$beg, $end);
+	my $nr = scalar @$msgs or return;
+
+	# OVERVIEW.FMT
+	more($self, join("\r\n", map {
+		over_line($self, $ng, $_->{num}, $_);
+		} @$msgs));
+	$$beg = $msgs->[-1]->{num} + 1;
+}
+
 sub cmd_xover ($;$) {
 	my ($self, $range) = @_;
 	$range = $self->{article} unless defined $range;
@@ -880,18 +893,7 @@ sub cmd_xover ($;$) {
 	return $r unless ref $r;
 	my ($beg, $end) = @$r;
 	more($self, "224 Overview information follows for $$beg to $end");
-	my $over = $self->{ng}->over;
-	my $cur = $$beg;
-	long_response($self, sub {
-		my $msgs = $over->query_xover($cur, $end);
-		my $nr = scalar @$msgs or return;
-
-		# OVERVIEW.FMT
-		more($self, join("\r\n", map {
-			over_line($self, $self->{ng}, $_->{num}, $_);
-			} @$msgs));
-		$cur = $msgs->[-1]->{num} + 1;
-	});
+	long_response($self, \&xover_i, @$r);
 }
 
 sub compressed { undef }

      parent reply	other threads:[~2019-12-21  8:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-21  7:59 [PATCH 0/8] nntp: eliminate response-duration cyclic refs Eric Wong
2019-12-21  8:00 ` [PATCH 1/8] nntp: get_range: return scalarref for $beg Eric Wong
2019-12-21  8:00 ` [PATCH 2/8] nntp: remove cyclic refs from long_response Eric Wong
2019-12-21  8:00 ` [PATCH 3/8] nntp: hdr_searchmsg: use named sub for numeric range response Eric Wong
2019-12-21  8:00 ` [PATCH 4/8] nntp: cmd_xrover: use named sub for long_response Eric Wong
2019-12-21  8:00 ` [PATCH 5/8] nntp: cmd_listgroup: use named subs " Eric Wong
2019-12-21  8:00 ` [PATCH 6/8] nntp: cmd_newnews: use named sub " Eric Wong
2019-12-21  8:00 ` [PATCH 7/8] nntp: hdr_msg_id: " Eric Wong
2019-12-21  8:00 ` Eric Wong [this message]

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

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191221080007.27810-9-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).