emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (aset UNIBYTE-STRING MULTIBYTE-CHAR)


From: Kenichi Handa
Subject: Re: (aset UNIBYTE-STRING MULTIBYTE-CHAR)
Date: Tue, 15 Apr 2008 16:11:20 +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)

The discussion on this problem has been suspended for long.
I'd like to settle it.

I wrote:

> In article <address@hidden>, Stefan Monnier <address@hidden> 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
address@hidden


*** 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));
      }
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]