lua-users home
lua-l archive

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


From: Curt Carpenter curtc@microsoft.com
> Sure, the strcmps were just illustrative of the problem. (strncmp + atoi
> is supposed to be better than just strcmp?)
Yes.  A single call to strncmp() + atoi() is much better than `n' calls to
strcmp().

> rely on the fact that lua_tostring returns
> a pointer to Lua's internal string, which means it's always the same,
> which means I can effectively treat that as an id. I really like that.
Agreed.  I wasn't aware of this feature/optimization in Lua until this
discussion; very nice.

> Is that going to break in 4.1?
Perhaps you can use lua_equal() to compare the strings, instead of a raw
pointer comparison.  Then, if the optimization goes away (which seems
unlikely), your programs won't break, only run somewhat more slowly.

--
Ryan Bright