From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Re: (aset UNIBYTE-STRING MULTIBYTE-CHAR) Date: Tue, 15 Apr 2008 16:11:20 +0900 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1208243574 23121 80.91.229.12 (15 Apr 2008 07:12:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Apr 2008 07:12:54 +0000 (UTC) Cc: kazu@iij.ad.jp To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 15 09:13:30 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JlfLC-0003QM-QK for ged-emacs-devel@m.gmane.org; Tue, 15 Apr 2008 09:12:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JlfKY-00045h-Cg for ged-emacs-devel@m.gmane.org; Tue, 15 Apr 2008 03:11:50 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JlfKU-00045c-Ik for emacs-devel@gnu.org; Tue, 15 Apr 2008 03:11:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JlfKT-00045Q-OO for emacs-devel@gnu.org; Tue, 15 Apr 2008 03:11:46 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JlfKT-00045N-Kt for emacs-devel@gnu.org; Tue, 15 Apr 2008 03:11:45 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JlfKT-0004f9-Aq for emacs-devel@gnu.org; Tue, 15 Apr 2008 03:11:45 -0400 Original-Received: from mx1.aist.go.jp ([150.29.246.133]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JlfKL-0005B4-7b for emacs-devel@gnu.org; Tue, 15 Apr 2008 03:11:42 -0400 Original-Received: from rqsmtp2.aist.go.jp (rqsmtp2.aist.go.jp [150.29.254.123]) by mx1.aist.go.jp with ESMTP id m3F7BNEm021858; Tue, 15 Apr 2008 16:11:23 +0900 (JST) env-from (handa@m17n.org) Original-Received: from smtp2.aist.go.jp by rqsmtp2.aist.go.jp with ESMTP id m3F7BMX7009810; Tue, 15 Apr 2008 16:11:22 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp2.aist.go.jp with ESMTP id m3F7BL7K027075; Tue, 15 Apr 2008 16:11:21 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken.m17n.org with local (Exim 4.69) (envelope-from ) id 1JlfK4-0007D2-PR; Tue, 15 Apr 2008 16:11:21 +0900 In-reply-to: message from Kenichi Handa on Mon, 18 Feb 2008 13:00:37 +0900 User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/23.0.60 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) X-detected-kernel: by mx20.gnu.org: Solaris 8 (1) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:95247 Archived-At: The discussion on this problem has been suspended for long. I'd like to settle it. I wrote: > In article , Stefan Monnier writes: > > > That inefficiency may or may not be important in any given context. > > > Fixing it in casefiddle is definitely desirable. > > > But is it worth breaking all such packages just so that they > > > will optimize an operation that might not use much of the time anyway? > > Why work around the problem in `aset' if it isn't worth fixing in the > > original code? > But you wrote: > > > Then, shouldn't we start the experiment of inhibitting aset > > > on strings just now? > > > > But I do not think we're ready for that. Maybe 10 years from now... > I want to avoid treating non-ASCII chars different from > ASCII. Then, the only solution is to make aset work well > for multibyte characters. The attached simple change does the work. May I install it? --- Kenichi Handa handa@ni.aist.go.jp *** lisp.h.~1.617.~ 2008-04-01 15:12:13.000000000 +0900 --- lisp.h 2008-04-15 15:42:52.000000000 +0900 *************** *** 725,730 **** --- 725,737 ---- (STR) = empty_unibyte_string; \ else XSTRING (STR)->size_byte = -1; } while (0) + /* Mark STR as a multibyte string. Assure that STR contains only + ASCII characters in advance. */ + #define STRING_SET_MULTIBYTE(STR) \ + do { if (EQ (STR, empty_unibyte_string)) \ + (STR) = empty_multibyte_string; \ + else XSTRING (STR)->size_byte = XSTRING (STR)->size; } while (0) + /* Get text properties. */ #define STRING_INTERVALS(STR) (XSTRING (STR)->intervals + 0) *** data.c.~1.290.~ 2008-03-27 20:16:37.000000000 +0900 --- data.c 2008-04-15 15:42:31.000000000 +0900 *************** *** 2093,2099 **** CHECK_NUMBER (newelt); if (XINT (newelt) >= 0 && ! SINGLE_BYTE_CHAR_P (XINT (newelt))) ! args_out_of_range (array, newelt); SSET (array, idxval, XINT (newelt)); } --- 2093,2109 ---- CHECK_NUMBER (newelt); if (XINT (newelt) >= 0 && ! SINGLE_BYTE_CHAR_P (XINT (newelt))) ! { ! int i; ! ! for (i = SBYTES (array) - 1; i >= 0; i--) ! if (SREF (array, i) >= 0x80) ! args_out_of_range (array, newelt); ! /* ARRAY is an ASCII string. Convert it to a multibyte ! string, and try `aset' again. */ ! STRING_SET_MULTIBYTE (array); ! return Faset (array, idx, newelt); ! } SSET (array, idxval, XINT (newelt)); }