[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua string
- From: David Given <dg@...>
- Date: Thu, 26 Apr 2007 14:44:22 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Luiz Henrique de Figueiredo wrote:
>> Is it possible to improve string operations performance in Lua?
Yeah, but that's cheating; it's using a different algorithm.
Having a quick shufty through the source code reveals that SpiderMonkey
distinguishes between mutable and immutable strings. Mutable strings can have
a preallocated buffer.
So what's probably going on here is that the concatenation is mostly being
done as a data copy, with no extra allocations needed. A neat trick.
Lua could do something similar, but this would require a rather more
complicated compiler and garbage collector, to intelligently decide whether to
use mutable or immutable strings...
┌── ｄｇ＠ｃｏｗｌａｒｋ．ｃｏｍ ─── http://www.cowlark.com ───────────────────
│ "Feminism encourages women to leave their husbands, kill their children,
│ practice withcraft, destroy capitalism and become lesbians." --- Rev. Pat
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----