lua-users home
lua-l archive

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


On Thursday 08 May 2003 13:46, Daniel Silverstone wrote:
> Sounds excellent.

Strings are fast in Lua, with a single exception (if compared with some other 
languages): frequent string concatenation.
That's been discussed on this list some time ago; the only situation where you 
pay a performance price is when you build a long string by repeatedly adding 
characters one at a time. In other words, Lua doesn't have a "buffer" (i.e. a 
mutable string) type.

You may, however, get a discount offer by using table.concat() to join many 
strings together in a single operation.

By the way, I wonder how efficient it would be to use a table of characters as 
a mutable "buffer" for very long strings (I know I should try it, but I have 
problems in this period). I mean how time-efficient, of course; I am well 
aware of the space cost involved in this approach.

  Enrico