* [PATCH 0/12] another round of NNTP updates
@ 2015-09-30 21:00 7% Eric Wong
2015-09-30 21:00 5% ` [PATCH 04/12] remove unnecessary fields usage Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2015-09-30 21:00 UTC (permalink / raw)
To: meta
This is probably performant enough for practical use :)
Eric Wong (12):
search: remove get_subject_path
nntp: HDR returns 225, not 224
nntp: reduce syscalls for LIST OVERVIEW.FMT
remove unnecessary fields usage
daemon: always autoflush stdout/stderr
nntpd: avoid lazy require
INSTALL: document Danga::Socket dependency for nntpd
nntp: MODE READER denies posting
nntp: implement LIST HEADERS
nntp: implement OVER/XOVER summary in search document
t/nntpd.t: simplify condition for response termination
t/nntpd.t: additional tests for XHDR/HDR
INSTALL | 2 +
lib/PublicInbox/Daemon.pm | 3 +
lib/PublicInbox/GitCatFile.pm | 5 +-
lib/PublicInbox/Hval.pm | 9 +--
lib/PublicInbox/Mbox.pm | 11 ++-
lib/PublicInbox/Msgmap.pm | 4 +-
lib/PublicInbox/NNTP.pm | 175 ++++++++++++++++++++----------------------
lib/PublicInbox/NewsGroup.pm | 25 +++---
lib/PublicInbox/Search.pm | 43 ++++++++---
lib/PublicInbox/SearchIdx.pm | 59 ++++++++++----
lib/PublicInbox/SearchMsg.pm | 86 +++++++++++++--------
lib/PublicInbox/SearchView.pm | 19 ++---
public-inbox-nntpd | 19 +++--
t/nntpd.t | 46 ++++++++++-
t/search.t | 2 +-
15 files changed, 305 insertions(+), 203 deletions(-)
^ permalink raw reply [relevance 7%]
* [PATCH 04/12] remove unnecessary fields usage
2015-09-30 21:00 7% [PATCH 0/12] another round of NNTP updates Eric Wong
@ 2015-09-30 21:00 5% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-09-30 21:00 UTC (permalink / raw)
To: meta
It doesn't actually give performance improvements unless we
use types with "my", but we don't do that. We'll only continue
using fields with Danga::Socket-derived classes where they're
required.
---
lib/PublicInbox/GitCatFile.pm | 5 +----
lib/PublicInbox/Hval.pm | 9 ++++-----
lib/PublicInbox/Mbox.pm | 11 +++++------
lib/PublicInbox/Msgmap.pm | 4 +---
lib/PublicInbox/NewsGroup.pm | 10 +++++-----
lib/PublicInbox/SearchView.pm | 19 ++++++++-----------
public-inbox-nntpd | 13 ++++++-------
7 files changed, 30 insertions(+), 41 deletions(-)
diff --git a/lib/PublicInbox/GitCatFile.pm b/lib/PublicInbox/GitCatFile.pm
index 5403696..629d23e 100644
--- a/lib/PublicInbox/GitCatFile.pm
+++ b/lib/PublicInbox/GitCatFile.pm
@@ -8,13 +8,10 @@ use strict;
use warnings;
use POSIX qw(dup2);
require IO::Handle;
-use fields qw(git_dir pid in out);
sub new {
my ($class, $git_dir) = @_;
- my $self = fields::new($class);
- $self->{git_dir} = $git_dir;
- $self;
+ bless { git_dir => $git_dir }, $class
}
sub _cat_file_begin {
diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index e0ec630..9fbe616 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -5,7 +5,6 @@
package PublicInbox::Hval;
use strict;
use warnings;
-use fields qw(raw href);
use Encode qw(find_encoding);
use URI::Escape qw(uri_escape_utf8);
use PublicInbox::MID qw/mid_clean/;
@@ -14,14 +13,14 @@ my $enc_ascii = find_encoding('us-ascii');
sub new {
my ($class, $raw, $href) = @_;
- my $self = fields::new($class);
# we never care about leading/trailing whitespace
$raw =~ s/\A\s*//;
$raw =~ s/\s*\z//;
- $self->{raw} = $raw;
- $self->{href} = defined $href ? $href : $raw;
- $self;
+ bless {
+ raw => $raw,
+ href => defined $href ? $href : $raw,
+ }, $class;
}
sub new_msgid {
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index c92d444..8bb8dc8 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -110,16 +110,15 @@ EOF
package PublicInbox::MboxGz;
use strict;
use warnings;
-use fields qw(gz fh buf);
sub new {
my ($class, $fh) = @_;
- my $self = fields::new($class);
my $buf;
- $self->{buf} = \$buf;
- $self->{gz} = IO::Compress::Gzip->new(\$buf);
- $self->{fh} = $fh;
- $self;
+ bless {
+ buf => \$buf,
+ gz => IO::Compress::Gzip->new(\$buf),
+ fh => $fh,
+ }, $class;
}
sub _flush_buf {
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm
index f285790..8a34e7e 100644
--- a/lib/PublicInbox/Msgmap.pm
+++ b/lib/PublicInbox/Msgmap.pm
@@ -4,7 +4,6 @@
package PublicInbox::Msgmap;
use strict;
use warnings;
-use fields qw(dbh mid_insert mid_for num_for num_minmax);
use DBI;
use DBD::SQLite;
@@ -23,8 +22,7 @@ sub new {
sqlite_use_immediate_transaction => 1,
});
$dbh->do('PRAGMA case_sensitive_like = ON');
- my $self = fields::new($class);
- $self->{dbh} = $dbh;
+ my $self = bless { dbh => $dbh }, $class;
if ($writable) {
create_tables($dbh);
diff --git a/lib/PublicInbox/NewsGroup.pm b/lib/PublicInbox/NewsGroup.pm
index 0c7051d..1250b0d 100644
--- a/lib/PublicInbox/NewsGroup.pm
+++ b/lib/PublicInbox/NewsGroup.pm
@@ -3,7 +3,6 @@
package PublicInbox::NewsGroup;
use strict;
use warnings;
-use fields qw(name git_dir address domain mm gcf search);
use Scalar::Util qw(weaken);
require Danga::Socket;
require PublicInbox::Msgmap;
@@ -11,12 +10,13 @@ require PublicInbox::GitCatFile;
sub new {
my ($class, $name, $git_dir, $address) = @_;
- my $self = fields::new($class);
- $self->{name} = $name;
$address = $address->[0] if ref($address);
+ my $self = bless {
+ name => $name,
+ git_dir => $git_dir,
+ address => $address,
+ }, $class;
$self->{domain} = ($address =~ /\@(\S+)\z/) ? $1 : 'localhost';
- $self->{git_dir} = $git_dir;
- $self->{address} = $address;
$self;
}
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index 6bc66ce..cfc650f 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -257,27 +257,24 @@ sub adump {
package PublicInbox::SearchQuery;
use strict;
use warnings;
-use fields qw(q o t x r);
use PublicInbox::Hval;
sub new {
my ($class, $cgi) = @_;
- my $self = fields::new($class);
- $self->{q} = $cgi->param('q');
- $self->{x} = $cgi->param('x') || '';
- $self->{o} = int($cgi->param('o') || 0) || 0;
- my $r = $cgi->param('r');
- $self->{r} = (defined $r && $r ne '0');
-
- $self;
+ my $r => $cgi->param('r'),
+ bless {
+ q => $cgi->param('q'),
+ x => $cgi->param('x') || '',
+ o => int($cgi->param('o') || 0) || 0,
+ r => (defined $r && $r ne '0'),
+ }, $class;
}
sub qs_html {
my ($self, %over) = @_;
if (keys %over) {
- my $tmp = fields::new(ref($self));
- %$tmp = %$self;
+ my $tmp = bless { %$self }, ref($self);
foreach my $k (keys %over) {
$tmp->{$k} = $over{$k};
}
diff --git a/public-inbox-nntpd b/public-inbox-nntpd
index f6042c2..79161fb 100644
--- a/public-inbox-nntpd
+++ b/public-inbox-nntpd
@@ -15,16 +15,15 @@ daemon_run('0.0.0.0:119',
package PublicInbox::NNTPD;
use strict;
use warnings;
-use fields qw(groups grouplist err out);
sub new {
my ($class) = @_;
- my $self = fields::new($class);
- $self->{groups} = {};
- $self->{err} = \*STDERR;
- $self->{out} = \*STDOUT;
- $self->{grouplist} = [];
- $self;
+ bless {
+ groups => {},
+ err => \*STDERR,
+ out => \*STDOUT,
+ grouplist => [],
+ }, $class;
}
sub refresh_groups () {
--
EW
^ permalink raw reply related [relevance 5%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-09-30 21:00 7% [PATCH 0/12] another round of NNTP updates Eric Wong
2015-09-30 21:00 5% ` [PATCH 04/12] remove unnecessary fields usage Eric Wong
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).