lua-users home
lua-l archive

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


Glenn Maynard wrote:
[...]
> You don't need bitwise operators to get bitwise operations, though.  What's
> wrong, in your case, with having them as functions?
>
>   netmask = math.or(netmask, 0x000000FF)

Functions are slow.

Your example for example, involves two table lookups and a call frame.
The patch I use uses extra opcodes, at a fraction of the overhead;
what's more, this allows the compiler to do constant folding. For example:

    netmask = netmask |
        0x12000000 |
        0x00340000 |
        0x00005600 |
        0x00000078

...can become a single opcode. (Although I don't know if my patch
actually does this.)

This may seem trivial, but given the way bitfields are commonly used,
you typically want speed.

-- 
David Given
dg@cowlark.com