lua-users home
lua-l archive

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


Alex Queiroz <asandroq@gmail.com> writes:

> On Thu, Nov 18, 2010 at 11:24 AM, Nilson <nilson.brazil@gmail.com> wrote:
>>
>> I had the same impression, but analyzing the resulted assembly code I
>> realized that the performance of switch depends on the compiler that
>> you use. Lua's team always defines the values used by the switch
>> statements in a minimal range (excellent design). So the compiler can
>> create a Table Of Address to jump to the case option.
>>
>
>      Ah, very interesting! I didn't know that, thank you.

I may be dull, but I don't see what about that code would not disturb
branch prediction and pipelining.

While it may coincide with the implementation I'd personally use in
assembly language for a VM, the cited reasons for lambasting other
"switch" implementations don't appear all too valid.

-- 
David Kastrup