Let's say that I want to store some alphanumeric data. I can either use a table:
t = { "a", "b", "c" }
or a string:
s = "abc"
When I want to test if 'b' is in my data set, I can test the table by saying:
function findInTable(table, element)
for i, v in ipairs(table) do
if v == element then return true end
end
return false
end
if findInTable(t, "b") then
--do stuff
or I can test the string by saying:
if s:find("b") then
--do stuff
Which of these methods is faster? I imagine that string.find is essentially doing the same thing as my findInTable function. I need to check data in this way on every draw for a game, so performance is critical. A lot of my data is being extracted from text files and it's easier to keep it in string format rather than using commas or some such as delimiters to organize it into table values.