lua-users home
lua-l archive

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


David Kastrup <dak@gnu.org> writes:

> Mike Pall <mikelu-0703@mike.de> writes:
>
>> David Kastrup wrote:
>
> Stop.  I was talking about hashing, you are talking about copying.
> Two different things.  While I admit that avoiding copying might at
> some point also be interesting, this is a problem that affects
> performance orders of magnitude less.
>
> If one fears that memory will fill up with identical strings
> otherwise, one can hash and fold strings as part of garbage
> collection, but that's a different story.

[Scheme for not copying but using the original data]

I'd like to point out that this copy avoidance scheme is _completely_
orthogonal to the hashing: it just concerns where the string
_contents_ are stored and who takes care of the memory when it is no
longer needed.

For example, Lua might at some point decide to hash a string, find
that it already has an identical string, and then tell the callback
that it does no longer need the string data.  It might also find that
it does not need the string data because the string itself has been
garbage collected.

But the allocation issue for the string data is really neither
specific to strings, nor strictly related to the matter of lazy
hashing.

-- 
David Kastrup