From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: performance of converting alist to hash table Date: Thu, 20 May 2004 08:27:30 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200405192327.IAA14876@etlken.m17n.org> References: <20040516095522.GA1625@SDF.LONESTAR.ORG> <4n3c5zj6eq.fsf@lifelogs.com> <20040517233743.GA11854@fencepost> <20040518115030.GA21952@SDF.LONESTAR.ORG> <20040519115903.GA2149@SDF.LONESTAR.ORG> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: sea.gmane.org 1085014211 10004 80.91.224.253 (20 May 2004 00:50:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 20 May 2004 00:50:11 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu May 20 02:49:57 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BQbkz-0003ta-00 for ; Thu, 20 May 2004 02:49:57 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BQbky-0005kO-00 for ; Thu, 20 May 2004 02:49:57 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BQbfb-0001TG-EO for emacs-devel@quimby.gnus.org; Wed, 19 May 2004 20:44:23 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BQbTn-0005NM-J1 for emacs-devel@gnu.org; Wed, 19 May 2004 20:32:11 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BQaTN-0007Sk-GW for emacs-devel@gnu.org; Wed, 19 May 2004 19:28:12 -0400 Original-Received: from [192.47.44.130] (helo=tsukuba.m17n.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BQaTL-0007S0-UP for emacs-devel@gnu.org; Wed, 19 May 2004 19:27:40 -0400 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2]) by tsukuba.m17n.org (8.11.6p2/8.11.6) with ESMTP id i4JNRVQ25201; Thu, 20 May 2004 08:27:31 +0900 (JST) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) by fs.m17n.org (8.11.6p2/8.11.6) with ESMTP id i4JNRUW06046; Thu, 20 May 2004 08:27:30 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id IAA14876; Thu, 20 May 2004 08:27:30 +0900 (JST) Original-To: daiyuwen@sdf.lonestar.org In-reply-to: <20040519115903.GA2149@SDF.LONESTAR.ORG> (message from Dai Yuwen on Wed, 19 May 2004 11:59:03 +0000) User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.3 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:23751 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:23751 In article <20040519115903.GA2149@SDF.LONESTAR.ORG>, Dai Yuwen writes: > [1 ] > On Tue, May 18, 2004 at 09:42:20AM -0400, Stefan Monnier wrote: >> > I use equal as the test function: >> > (setq ta (make-hash-table :test 'equal :size 7000)) >> >> > But I forgot to mention: the key of hash is a Chinese GB2312 >> > string. Does this slow down hashing? >> >> Can you post your complete code so we can reproduce the problem? >> >> > I attach the el file in the mail. There're GB2312 strings in the alist. As keys are all one-char strings, I think a char-table is the most efficient method. (put 'wubi-table 'char-table-extra-slots 0) (defvar wubi-table (make-char-table 'wubi-table nil)) (defun convert-alist-to-char-table (table w) (mapc #'(lambda (e) (aset table (aref (car e) 0) (cadr e))) w)) ;;;; WuBi code for single Chinese char (convert-alist-to-char-table wubi-table '( [...] You can access the value by (aref wubi-table ?_CHINESE_CHAR_), which is also very fast compared to gethash and assq. If you also want a reverse mapping (i.e. WuBi to chinese char), you can use nested-alist. --- Ken'ichi HANDA handa@m17n.org