lua-users home
lua-l archive

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


On Saturday, May 03, 2014 05:09:14 AM Coroutines wrote:
> I like your proposal, but I feel (without benchmarking) that comparing
> 2 integers would be quicker than first finding out if a short string
> is long enough to cast the comparison to 2 integers/doubles
> (word/dword comparison).

Never make assumptions without benchmarks. (I fell into that trap during the 
recent discussion about metatables on lightuserdata.) A quick test of running 
1e9 single-byte string comparisons versus the number comparisons using Lua 
5.2, they were roughly the same. In fact, the string test was very slightly 
faster.

Your initial premise is flawed. Comparing character codes as numbers is not 
more advantageous than comparing the strings themselves. Thus there is no 
advantage to your proposal.

-- 
tom <telliamed@whoopdedo.org>