From mboxrd@z Thu Jan 1 00:00:00 1970 From: rlane@club.cc.cmu.edu (Rich Lane) Date: Sat, 22 Aug 2009 11:54:23 -0700 Subject: [sup-talk] [PATCH] add xapian-specific hack to quickly create a Person In-Reply-To: <1250965695-31073-1-git-send-email-rlane@club.cc.cmu.edu> References: <1250965695-31073-1-git-send-email-rlane@club.cc.cmu.edu> Message-ID: <1250967263-31292-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