emacs-devel
[Top][All Lists]
Advanced

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

Re: Proposal: immediate strings


From: Paul Eggert
Subject: Re: Proposal: immediate strings
Date: Wed, 23 May 2012 23:08:15 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

On 05/23/2012 10:17 PM, Stefan Monnier wrote:
> maybe we can move both the mark bit and the immbit into the `intervals'
> fields (after all, we know those are aligned on a multiple of at least
> 4 on all architectures on which Emacs is known to run, so we have
> 2 bits free for (ab)use there).

That might work.  But this raises another idea: assuming most tiny strings
don't have text properties, won't it improve performance overall if
any string with text properties is forced to be an ordinary string, so
that immediate strings can reuse the rarely-used 'intervals' member
for data?

Another thought that comes to mind, is that we could leave
the mark bit where it is (the most significant bit of 'size'),
and reserve 'size' values >= (EMACS_INT / 2 & ~0xffff)
to represent immediate strings, with the size and size_bytes
values packed into the low-order 16 bits of 'size'.
Something like this:

   struct Lisp_String
     {
       EMACS_INT size;
       union
         {
           struct Ordinary_Lisp_String_Component
             {
               EMACS_INT size_byte;
               INTERVAL intervals;
               unsigned char *data;
             } ordinary;
           unsigned char data[sizeof (struct Ordinary_Lisp_String_Component)];
       } u;
     };

   #define IMMEDIATE_STRING(s) (EMACS_INT_MAX & ~0xffff <= (s)->size)
   #define SDATA(s) (IMMEDIATE_STRING (XSTRING (s)) \
                     ? XSTRING (s)->data \
                     : XSTRING (s)->ordinary.data)
   #define SCHARS(s) (IMMEDIATE_STRING (XSTRING (s)) \
                      ? XSTRING (s)->size & 0xff
                      : XSTRING (s)->size)
   #define SBYTES(s) (IMMEDIATE_STRING (XSTRING (s)) \
                      ? (XSTRING (s)->size >> 8) & 0xff
                      : STRING_BYTES (XSTRING (s)))

etc.




reply via email to

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