lua-users home
lua-l archive

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


On 13 December 2010 19:48, Mike McGonagle <mjmogo@gmail.com> wrote:
> Hello all,
>
> I was wondering if anyone could tell me how "memory" efficient Lua is
> for dealing with text processing? I would like to use it as a
> scripting language to do some template generation for another
> programming language. I guess what I am wondering is if Lua only deals
> with "static" strings, is there a point where the amount of memory
> used becomes cumbersome to deal with?
>
> I guess I am wondering if there is a way, like in Java, to create a
> "StringBuffer" object in lua, so that all these strings do not live
> permanently in memory.
>
> Is this really something I should worry about? I ask because I kind of
> envision having Lua running for some time while processing various
> files? Or should I have these "text processes" run as a call to
> os.execute, which would then either create a text file, or return the
> finished string to the caller?

When concatenating a lot of strings, it is always better to put the
strings into a table, and then use table.concat() to get the resulting
string. Take a look at http://luafaq.org/#T1.9