emacs-devel
[Top][All Lists]
Advanced

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

Re: Quesition about Lisp_Vector


From: Eli Zaretskii
Subject: Re: Quesition about Lisp_Vector
Date: Sat, 12 Nov 2011 10:49:45 +0200

> From: "Stephen J. Turnbull" <address@hidden>
> Date: Sat, 12 Nov 2011 12:42:42 +0900
> Cc: Qiang Guo <address@hidden>, address@hidden
> 
> Aside to OP: In Emacs Lisp although strings (ie, arrays with bytes as
> elements and a non-uniform indexing scheme) are vectors in the API,
> they don't share an implementation with general vectors.  In fact the
> string storage is allocated separately (another optimization, because
> strings with len(data) % pointersize != 0 would waste substantial
> amounts of memory, at least by 1980 standards), so there's always a
> pointer indirection.  This usually is not too inefficient since many
> operations on strings are of the form "get string data, do O(len)
> operation on it", so the overhead of a pointer dereference to "get
> string data" is tolerable.

Having string data accessible through indirection allows to relocate
strings without affecting callers who have references to Lisp strings
in local variables.  (This is similar to the ability to relocate
buffer text, because buffer text is also accessed through
indirection.)  These abilities are important, because strings, like
buffers, can be large, so being able to relocate them during GC helps
making more efficient use of the available memory.



reply via email to

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