[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Table lookups versus String matching
- From: Luis F Urrea <lfurrea@...>
- Date: Wed, 25 Feb 2009 13:38:49 -0600
Hi all,
Our team is learning the subtleties of LUA and we are on a small newbies debate.
We are wondering what would be cheaper between calling a function from a table lookup or a string matching function.
Basically we have a Table that stores the name of the function. When a state machine runs and returns the name of the function we have the option to do this:
local actions = { pAuthRequest = function ()
print("Auth request coming!")
end,
ClientSend = function ()
master:send(auth_string)
end,
pCommandReply = function ()
print("Woohooo")
end,
pWaiting = function ()
print("Waiting for more")
end,
}
local action = ""> action()
Or this instead:
function actions(action)
if action ="" then
print("Auth request coming!")
end
<snip>
actions(a.action)
Hope the description above is clear enough so that you guys can shed some light on this.
Thanks in advance!