lua-users home
lua-l archive

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Luiz Henrique de Figueiredo wrote:
>> Is it possible to improve string operations performance in Lua?
> 
> http://www.lua.org/pil/11.6.html 

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...

- --
┌── dg@cowlark.com ─── http://www.cowlark.com ───────────────────
│ "Feminism encourages women to leave their husbands, kill their children,
│ practice withcraft, destroy capitalism and become lesbians." --- Rev. Pat
│ Robertson
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGMKy2f9E0noFvlzgRAlVWAJ0SSvKMPsaYuvGxGCmTzojrvZoArACdE4Nf
bb5AJyo0P2umE/67LlYHFVc=
=AOZ2
-----END PGP SIGNATURE-----