jeudi 26 mars 2015

lua table values to a string- performance issue

I have a lua code where a certain table (lets say 'abc') has 50,000 key value pairs. Now i want to create a long string which will look like "(key1, value1) (key2,value2) (key3, value3) ... ".


This works for tables with smaller number of elements. for 50,000 it works but the pc becomes very very slow. Is there a way around this ?


I tried inserting in to another table and then concatenating since the string concatenation in lua is expensive but still the performance penalty is there



local pqr = {}
for key, value in pairs(app_revenue) do
table.insert(pqr, "(")
table.insert(pqr, key)
table.insert(pqr, ",")
table.insert(pqr, value)
table.insert(pqr, ") ")
end
local x = table.concat(pqr)


Any insight on this issue is much appreciated. Thank you


Aucun commentaire:

Enregistrer un commentaire