user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 8/9] searchmsg: favor direct hash access over accessor methods
  2017-01-07  1:44  6% [PATCH 0/9] misc cleanups and trimming Eric Wong
@ 2017-01-07  1:44  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2017-01-07  1:44 UTC (permalink / raw)
  To: meta

This is faster, smaller, and more straighforward to me with
fewer layers of indirection.
---
 lib/PublicInbox/Inbox.pm     |  3 ++-
 lib/PublicInbox/Search.pm    |  2 +-
 lib/PublicInbox/SearchIdx.pm |  4 ++--
 lib/PublicInbox/SearchMsg.pm | 33 ++-------------------------------
 4 files changed, 7 insertions(+), 35 deletions(-)

diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index f77944f..aa4e141 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -216,7 +216,8 @@ sub msg_by_smsg ($$;$) {
 
 	# backwards compat to fallback to msg_by_mid
 	# TODO: remove if we bump SCHEMA_VERSION in Search.pm:
-	defined(my $blob = $smsg->blob) or return msg_by_mid($self, $smsg->mid);
+	defined(my $blob = $smsg->{blob}) or
+			return msg_by_mid($self, $smsg->mid);
 
 	my $str = git($self)->cat_file($blob, $ref);
 	$$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s if $str;
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index b59430d..86354b5 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -282,7 +282,7 @@ sub lookup_message {
 		# raises on error:
 		my $doc = $self->{xdb}->get_document($doc_id);
 		$smsg = PublicInbox::SearchMsg->wrap($doc, $mid);
-		$smsg->doc_id($doc_id);
+		$smsg->{doc_id} = $doc_id;
 	}
 	$smsg;
 }
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 832d1cb..87ee0d4 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -155,7 +155,7 @@ sub add_message {
 		if ($smsg) {
 			# convert a ghost to a regular message
 			# it will also clobber any existing regular message
-			$doc_id = $smsg->doc_id;
+			$doc_id = $smsg->{doc_id};
 			$old_tid = $smsg->thread_id;
 		}
 		$smsg = PublicInbox::SearchMsg->new($mime);
@@ -289,7 +289,7 @@ sub link_message {
 	my ($self, $smsg, $old_tid) = @_;
 	my $doc = $smsg->{doc};
 	my $mid = $smsg->mid;
-	my $mime = $smsg->mime;
+	my $mime = $smsg->{mime};
 	my $hdr = $mime->header_obj;
 	my $refs = $hdr->header_raw('References');
 	my @refs = $refs ? ($refs =~ /<([^>]+)>/g) : ();
diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm
index 4522eb6..5bb0077 100644
--- a/lib/PublicInbox/SearchMsg.pm
+++ b/lib/PublicInbox/SearchMsg.pm
@@ -103,7 +103,7 @@ sub from_name {
 
 sub ts {
 	my ($self) = @_;
-	$self->{ts} ||= eval { str2time($self->mime->header('Date')) } || 0;
+	$self->{ts} ||= eval { str2time($self->{mime}->header('Date')) } || 0;
 }
 
 sub to_doc_data {
@@ -146,36 +146,7 @@ sub mid ($;$) {
 	}
 }
 
-sub _extract_mid { mid_clean(mid_mime($_[0]->mime)) }
-
-sub blob {
-	my ($self, $x40) = @_;
-	if (defined $x40) {
-		$self->{blob} = $x40;
-	} else {
-		$self->{blob};
-	}
-}
-
-sub mime {
-	my ($self, $mime) = @_;
-	if (defined $mime) {
-		$self->{mime} = $mime;
-	} else {
-		# TODO load from git
-		$self->{mime};
-	}
-}
-
-sub doc_id {
-	my ($self, $doc_id) = @_;
-	if (defined $doc_id) {
-		$self->{doc_id} = $doc_id;
-	} else {
-		# TODO load from xapian
-		$self->{doc_id};
-	}
-}
+sub _extract_mid { mid_clean(mid_mime($_[0]->{mime})) }
 
 sub thread_id {
 	my ($self) = @_;
-- 
EW


^ permalink raw reply related	[relevance 7%]

* [PATCH 0/9] misc cleanups and trimming
@ 2017-01-07  1:44  6% Eric Wong
  2017-01-07  1:44  7% ` [PATCH 8/9] searchmsg: favor direct hash access over accessor methods Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2017-01-07  1:44 UTC (permalink / raw)
  To: meta

Weak reference dependencies are entirely gone.  This should
simplify the internal object structures of Perl a bit and
hopefully make the data structures easier to reason about.

While we're at it, there's several search-related cleanups
to eliminate some dead code.

9 changes:

      qspawn: prepare to support runtime reloading of Limiter
      config: always use namespaced "publicinboxlimiter"
      config: remove unused get() method
      inbox: describe the full key name
      inbox: eliminate weaken usage entirely
      config: allow per-inbox nntpserver
      remove incorrect comment about strftime + locales
      searchmsg: favor direct hash access over accessor methods
      search: remove subject_summary


 lib/PublicInbox/Config.pm        | 14 ++------
 lib/PublicInbox/Inbox.pm         | 73 ++++++++++++++++++----------------------
 lib/PublicInbox/Qspawn.pm        | 11 ++++--
 lib/PublicInbox/Search.pm        | 29 ++--------------
 lib/PublicInbox/SearchIdx.pm     |  4 +--
 lib/PublicInbox/SearchMsg.pm     | 36 +++-----------------
 lib/PublicInbox/WwwAtomStream.pm |  1 -
 t/config.t                       | 25 ++++++++++++--
 t/config_limiter.t               | 11 +++---
 t/search.t                       | 17 ----------
 10 files changed, 78 insertions(+), 143 deletions(-)


^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2017-01-07  1:44  6% [PATCH 0/9] misc cleanups and trimming Eric Wong
2017-01-07  1:44  7% ` [PATCH 8/9] searchmsg: favor direct hash access over accessor methods 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).