lua-users home
lua-l archive

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


On Thu, Mar 01, 2007 at 04:22:34PM -0800, gary ng wrote:
> thanks and that is why I asked if there is any
> concern. What I would like to know though is what is
> the consequence if I do change the content. It
> invalidate the hash, would it break the GC ? 

GC isn't the problem, AFAIK. When you modify a string, if there is ANY
other piece of code in the system that has an identical valued string,
"both" (actually, there will only be one) of those strings get changed.
This runs the risk of causing chaos, as you can imagine!

And you mention wanting to interop with the zip library, for example...
what if it collects a list of strings you pass it locally, and then only
concatenates and flushes the lists at some later time? Meanwhile, every
string you pass it is the same string (as far as lua knows), but you
have been overwriting its data buffer with new data. This will be nasty.

Anyhow, I'm just repeating the information about internalized strings
from

  http://www.tecgraf.puc-rio.br/~lhf/ftp/doc/jucs05.pdf

I suspect if you just used strings, and benchmarks show your performance
is dominated by string creation overhead, experts around here might be
able to provide useful suggestions for optimizing your app.

Cheers,
Sam