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 1/8] nntp: get_range: return scalarref for $beg
Date: Sat, 21 Dec 2019 08:00:00 +0000	[thread overview]
Message-ID: <20191221080007.27810-2-e@80x24.org> (raw)
In-Reply-To: <20191221080007.27810-1-e@80x24.org>

...Instead of just returning a plain scalar inside an arrayref.

This is because we usually pass the result of NNTP::get_range to
Msgmap::msg_range.  Upcoming changes will move us away from
anonymous subroutines, so this change will make followup commits
easier-to-digest as modifications to the underlying scalar can
be more easily propagated between non-anonymous-subs.
---
 lib/PublicInbox/NNTP.pm | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 6cd2b84c..cd5d7bba 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -204,7 +204,7 @@ sub cmd_listgroup ($;$$) {
 		return $r unless ref $r;
 		my ($beg, $end) = @$r;
 		long_response($self, sub {
-			$r = $mm->msg_range(\$beg, $end, 'num');
+			$r = $mm->msg_range($beg, $end, 'num');
 			scalar(@$r) or return;
 			more($self, join("\r\n", map { $_->[0] } @$r));
 			1;
@@ -593,7 +593,7 @@ sub get_range ($$) {
 	$beg = $min if ($beg < $min);
 	$end = $max if ($end > $max);
 	return '420 No article(s) selected' if ($beg > $end);
-	[ $beg, $end ];
+	[ \$beg, $end ];
 }
 
 sub long_response ($$) {
@@ -661,7 +661,7 @@ sub hdr_message_id ($$$) { # optimize XHDR Message-ID [range] for slrnpull.
 		my ($beg, $end) = @$r;
 		more($self, $xhdr ? r221 : r225);
 		long_response($self, sub {
-			my $r = $mm->msg_range(\$beg, $end);
+			my $r = $mm->msg_range($beg, $end);
 			@$r or return;
 			more($self, join("\r\n", map {
 				"$_->[0] <$_->[1]>"
@@ -704,7 +704,7 @@ sub hdr_xref ($$$) { # optimize XHDR Xref [range] for rtin
 		my ($beg, $end) = @$r;
 		more($self, $xhdr ? r221 : r225);
 		long_response($self, sub {
-			my $r = $mm->msg_range(\$beg, $end);
+			my $r = $mm->msg_range($beg, $end);
 			@$r or return;
 			more($self, join("\r\n", map {
 				my $num = $_->[0];
@@ -737,7 +737,7 @@ sub hdr_searchmsg ($$$$) {
 		return $r unless ref $r;
 		my ($beg, $end) = @$r;
 		more($self, $xhdr ? r221 : r225);
-		my $cur = $beg;
+		my $cur = $$beg;
 		long_response($self, sub {
 			my $msgs = $over->query_xover($cur, $end);
 			my $nr = scalar @$msgs or return;
@@ -823,9 +823,9 @@ sub cmd_xrover ($;$) {
 	more($self, '224 Overview information follows');
 
 	long_response($self, sub {
-		my $h = over_header_for($over, $beg, 'references');
-		more($self, "$beg $h") if defined($h);
-		$beg++ < $end;
+		my $h = over_header_for($over, $$beg, 'references');
+		more($self, "$$beg $h") if defined($h);
+		$$beg++ < $end;
 	});
 }
 
@@ -870,9 +870,9 @@ sub cmd_xover ($;$) {
 	my $r = get_range($self, $range);
 	return $r unless ref $r;
 	my ($beg, $end) = @$r;
-	more($self, "224 Overview information follows for $beg to $end");
+	more($self, "224 Overview information follows for $$beg to $end");
 	my $over = $self->{ng}->over;
-	my $cur = $beg;
+	my $cur = $$beg;
 	long_response($self, sub {
 		my $msgs = $over->query_xover($cur, $end);
 		my $nr = scalar @$msgs or return;

  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 ` Eric Wong [this message]
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 ` [PATCH 8/8] nntp: cmd_xover: " Eric Wong

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