lua-users home
lua-l archive

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


On Thursday, December 05, 2013 09:45:06 AM Marc Lepage wrote:
> I guess I'd still be looping (or if-else-if-ing) over a list of pointers
> for which to compare, if I can't statically embed that dispatch as a switch
> statement (the pointers vary at runtime). Better than a strcmp, but now I'm
> thinking a table of string-to-integer is probably going to be best.

The cost of building the table may dominate runtime if the function is called 
infrequently. So perhaps you'd want to only memoize strings that are being 
used. And don't forget bsearch if you can promise the C array will be sorted.

-- 
tom <telliamed@whoopdedo.org>