Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: rlane@club.cc.cmu.edu (Rich Lane)
Subject: [sup-talk] [PATCH] add xapian-specific hack to quickly create a Person
Date: Sat, 22 Aug 2009 11:54:23 -0700	[thread overview]
Message-ID: <1250967263-31292-1-git-send-email-rlane@club.cc.cmu.edu> (raw)
In-Reply-To: <1250965695-31073-1-git-send-email-rlane@club.cc.cmu.edu>

Another 10% query performance boost.
---
 lib/sup/xapian_index.rb |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb
index c260728..3a23951 100644
--- a/lib/sup/xapian_index.rb
+++ b/lib/sup/xapian_index.rb
@@ -74,7 +74,7 @@ class XapianIndex < BaseIndex
     m = Message.new :source => source, :source_info => entry[:source_info],
                     :labels => entry[:labels], :snippet => entry[:snippet]
 
-    mk_person = lambda { |x| Person.new(*x.reverse!) }
+    mk_person = lambda { |x| QuickPerson.new(*x) }
     entry[:from] = mk_person[entry[:from]]
     entry[:to].map!(&mk_person)
     entry[:cc].map!(&mk_person)
@@ -84,6 +84,14 @@ class XapianIndex < BaseIndex
     m
   end
 
+  class QuickPerson < Person
+    def initialize email, name
+      raise ArgumentError, "email can't be nil" unless email
+      @email = email
+      @name = name
+    end
+  end
+
   def add_message m; sync_message m end
   def update_message m; sync_message m end
   def update_message_state m; sync_message m end
-- 
1.6.4



  reply	other threads:[~2009-08-22 18:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-22 18:28 [sup-talk] [PATCH] add Message#load_from_index! shortcut Rich Lane
2009-08-22 18:54 ` Rich Lane [this message]
2009-08-24 23:24   ` [sup-talk] [PATCH] add xapian-specific hack to quickly create a Person William Morgan
2009-08-26  1:50     ` Rich Lane
2009-09-01 20:59       ` William Morgan
2009-08-24 23:23 ` [sup-talk] [PATCH] add Message#load_from_index! shortcut William Morgan

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1250967263-31292-1-git-send-email-rlane@club.cc.cmu.edu \
    --to=rlane@club.cc.cmu.edu \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox