about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-09-30 21:00:19 +0000
committerEric Wong <e@80x24.org>2015-09-30 21:09:18 +0000
commit709a1979302ef5dbb40babb84821b079868490a1 (patch)
treed38f9785c0ffebc1f36e3d7916ca75467e2fe8e9 /lib
parentebf564bad83e0c160b5088c7aaa9862d47735226 (diff)
downloadpublic-inbox-709a1979302ef5dbb40babb84821b079868490a1.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/GitCatFile.pm5
-rw-r--r--lib/PublicInbox/Hval.pm9
-rw-r--r--lib/PublicInbox/Mbox.pm11
-rw-r--r--lib/PublicInbox/Msgmap.pm4
-rw-r--r--lib/PublicInbox/NewsGroup.pm10
-rw-r--r--lib/PublicInbox/SearchView.pm19
6 files changed, 24 insertions, 34 deletions
diff --git a/lib/PublicInbox/GitCatFile.pm b/lib/PublicInbox/GitCatFile.pm
index 54036961..629d23ed 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 e0ec6305..9fbe616f 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 c92d4447..8bb8dc83 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 f2857908..8a34e7e0 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 0c7051db..1250b0d8 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 6bc66ceb..cfc650f4 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};
                 }