[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using empty_string as the only "" string
From: |
Stefan Monnier |
Subject: |
Re: Using empty_string as the only "" string |
Date: |
Tue, 24 Apr 2007 13:48:51 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.97 (gnu/linux) |
> probably I've missed something, but what's the reason(s) to have a
> lot of "" (zero-length) strings ? Why not uniq them into the only
> one ?
Because it has the disadvantage of leading to subtly different behavior,
while the benefit is at best very marginal, if any.
Stefan
PS: But if you're interested in such small optimizations, I have another one
in my local Emacs where the Lisp_String data type is changed to:
struct Lisp_String
{
EMACS_INT size;
EMACS_INT size_byte : BITS_PER_EMACS_INT - 1;
unsigned inlined : 1; /* 0 -> ptr, 1 -> chars; in union below. */
INTERVAL intervals; /* text properties in this string */
union
{
unsigned char *ptr;
unsigned char chars[STRING_MAXINLINE];
} data;
};
this way, on 32bit systems, strings of up to 3 bytes can be represented with
just a Lisp_String without any `sdata'. On 64bit systems, this can be used
for strings up to 7 bytes long (i.e. almost 50% of all allocated strings,
IIRC). And it can also be used for all the strings in the pure space (no
matter how long), so it saves about 50KB of pure space (can't remember the
exact number, but IIRC it was more than 10KB and less than 100KB).
- Re: Using empty_string as the only "" string, (continued)
- Re: Using empty_string as the only "" string, Juanma Barranquero, 2007/04/24
- Re: Using empty_string as the only "" string, Miles Bader, 2007/04/24
- Re: Using empty_string as the only "" string, Johan Bockgård, 2007/04/24
- Re: Using empty_string as the only "" string, Miles Bader, 2007/04/24
- Re: Using empty_string as the only "" string, Richard Stallman, 2007/04/25
- Re: Using empty_string as the only "" string, Daniel Brockman, 2007/04/26
- Re: Using empty_string as the only "" string, Richard Stallman, 2007/04/27
- Re: Using empty_string as the only "" string, Richard Stallman, 2007/04/24
- Re: Using empty_string as the only "" string, Juanma Barranquero, 2007/04/25
Re: Using empty_string as the only "" string, Richard Stallman, 2007/04/24
Re: Using empty_string as the only "" string,
Stefan Monnier <=
Re: Using empty_string as the only "" string, Richard Stallman, 2007/04/24
Re: using empty_string as the only "" string, dmantipov, 2007/04/25
Re: using empty_string as the only "" string, Richard Stallman, 2007/04/26