]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchMsg.pm
doc: various overview-level module comments
[public-inbox.git] / lib / PublicInbox / SearchMsg.pm
index 6c0780e5906424f845bafd2e3f14ed09e849e620..32cceb25065cf798ba497f8ea06f5f60c8f02c5f 100644 (file)
@@ -3,12 +3,15 @@
 # based on notmuch, but with no concept of folders, files or flags
 #
 # Wraps a document inside our Xapian search index.
+# There may be many of these objects loaded in memory at once
+# for large threads in our WWW UI.
 package PublicInbox::SearchMsg;
 use strict;
 use warnings;
 use PublicInbox::MID qw/mid_clean mid_mime/;
 use PublicInbox::Address;
 use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
+use Time::Local qw(timegm);
 
 sub new {
        my ($class, $mime) = @_;
@@ -44,13 +47,11 @@ sub to_doc_data {
                $self->cc,
                $oid,
                $mid0,
-               $self->ds,
-               $self->{bytes},
-               $self->{lines}
+               $self->{bytes} || '',
+               $self->{lines} || ''
        );
 }
 
-
 sub load_from_data ($$) {
        my ($self) = $_[0]; # data = $_[1]
        (
@@ -65,7 +66,6 @@ sub load_from_data ($$) {
 
                $self->{blob},
                $self->{mid},
-               $self->{ds},
                $self->{bytes},
                $self->{lines}
        ) = split(/\n/, $_[1]);
@@ -75,7 +75,10 @@ sub load_expand {
        my ($self) = @_;
        my $doc = $self->{doc};
        my $data = $doc->get_data or return;
-       $self->{ts} = get_val($doc, &PublicInbox::Search::TS);
+       $self->{ts} = get_val($doc, PublicInbox::Search::TS());
+       my $dt = get_val($doc, PublicInbox::Search::DT());
+       my ($yyyy, $mon, $dd, $hh, $mm, $ss) = unpack('A4A2A2A2A2A2', $dt);
+       $self->{ds} = timegm($ss, $mm, $hh, $dd, $mon - 1, $yyyy);
        utf8::decode($data);
        load_from_data($self, $data);
        $self;
@@ -90,7 +93,6 @@ sub load_doc {
 # :bytes and :lines metadata in RFC 3977
 sub bytes ($) { $_[0]->{bytes} }
 sub lines ($) { $_[0]->{lines} }
-sub num ($) { $_[0]->{num} ||= _get_term_val($_[0], 'XNUM', qr/\AXNUM/) }
 
 sub __hdr ($$) {
        my ($self, $field) = @_;
@@ -100,7 +102,7 @@ sub __hdr ($$) {
        my $mime = $self->{mime} or return;
        $val = $mime->header($field);
        $val = '' unless defined $val;
-       $val =~ tr/\n/ /;
+       $val =~ tr/\t\n/  /;
        $val =~ tr/\r//d;
        $self->{$field} = $val;
 }
@@ -186,9 +188,4 @@ sub mid ($;$) {
 
 sub _extract_mid { mid_clean(mid_mime($_[0]->{mime})) }
 
-sub tid { $_[0]->{tid} }
-
-# XXX: consider removing this, we can phrase match subject
-sub path { $_[0]->{path} }
-
 1;