lua-users home
lua-l archive

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


Am 13.12.2010 19:48, schrieb Mike McGonagle:
I was wondering if anyone could tell me how "memory" efficient Lua is
for dealing with text processing?
:::
Is this really something I should worry about?
You must tell us more about your application. If it is a single shot it migh be fine to read the whole text once into one big string (as long as it fits into memory and leave some room for the rest to live) and then parse it using a position and bound pattern matching (eg: local a,b,item=find(text,"^([a-z][a-z0-9]*)",pos) if item then do_something_with(item) pos=b+1 end) [proud mode on] I just did an xml-parser that way in pure lua, which managed to parse xml output of mysqldump at an speed of 29MB/second (@i7-860) and returns all in a lua table-of-tables[/proud mode off] (just heavy optimized, what I've found at http://lua-users.org/wiki/LuaXml :-)

Regards Jørgen