[mew-dist 28650] Re: cmew

KOIE Hidetaka ( 鯉江英隆 ) hide at example.com
2008年 10月 7日 (火) 18:24:43 JST


  Message-Id: <20081007.153125.235203375.kazu at example.com>
  Date:       Tue, 07 Oct 2008 15:31:25 +0900 (JST)
  From:       Kazu Yamamoto (山本和彦) <kazu at example.com>
  Subject:    [mew-dist 28649] cmew

  | というわけで、cmew を変更したところ、"V" などが劇的に速くなりました。

「Generation search algorithm for smew」が不要なほど速くなったので
quoteの問題をスマートなplace-holder '?'で直すパッチです。

Index: smew
===================================================================
RCS file: /cvsmew/mew/bin/smew,v
retrieving revision 1.8
diff -u -p -r1.8 smew
--- smew	24 Sep 2008 05:47:30 -0000	1.8
+++ smew	7 Oct 2008 09:22:28 -0000
@@ -15,13 +15,9 @@ require 'sqlite3'
 ## DB search
 ##
 
-def xxquote(s)
-  s ? SQLite3::Database.quote(s) : nil
-end
-
 def select_by_id(hash, db, id, mydir)
   ret = nil
-  db.execute("SELECT * FROM mew WHERE (mew.id = '#{xxquote(id)}');") do |ent|
+  db.execute("SELECT * FROM mew WHERE (mew.id = ?);", id) do |ent|
     if push_results(hash, ent, mydir)
       ret = ent
     end
@@ -29,16 +25,9 @@ def select_by_id(hash, db, id, mydir)
   return ret
 end
 
-def select_by_parid(hash, db, idvec, mydir)
+def select_by_parid(hash, db, id, mydir)
   ret = []
-  cond = ""
-  idvec.each do |id|
-    if cond != ""
-      cond += " OR "
-    end
-    cond += "mew.parid = '#{xxquote(id)}'"
-  end
-  db.execute("SELECT * FROM mew WHERE (#{cond});") do |ent|
+  db.execute("SELECT * FROM mew WHERE (mew.parid = ?);", id) do |ent|
     if push_results(hash, ent, mydir)
       ret.push(ent)
     end
@@ -91,13 +80,13 @@ def search_ancestors(hash, db, parid, my
 end
 
 def search_descendants(hash, db, myid, mydir)
-  parents = select_by_parid(hash, db, [myid], mydir)
+  parents = select_by_parid(hash, db, myid, mydir)
   while parents != []
-    idvec = []
+    children = []
     parents.each do |ent|
-      idvec.push(ent['id'])
+      children += select_by_parid(hash, db, ent['id'], mydir)
     end
-    parents = select_by_parid(hash, db, idvec, mydir)
+    parents = children
   end
 end

--
KOIE Hidetaka <hide at example.com>



Mew-dist メーリングリストの案内