lua-users home
lua-l archive

Re: bit.lshift and performance - luabitop v.s. lua-5.2.0-work4

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


> On Wed, Oct 13, 2010 at 1:12 AM, KHMan <keinhong@gmail.com> wrote:
>> On 10/13/2010 10:34 AM, David Manura wrote:
>>>  local bits = bit.band(buffer, bit.lshift(1, nbits)-1)
>> ...Is there any actual technical problem with using this instead?
>>    bit.rshift(0xFFFFFFFF, 32 - nbits)
One downside is that the code
 local bits = bit.band(buffer, rshift(0xffffffff, 32 - nbits))
 buffer = bit.rshift(buffer, nbits)
now requires two special cases: nbits == 0 and nbits == 32. Both
actually occur in my code. I don't know if this is a rare case, but
it can affect code containing shifts by both n and 32 - n where n in
[0, 32].

AltStyle によって変換されたページ (->オリジナル) /