[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: bit.lshift and performance - luabitop v.s. lua-5.2.0-work4
- From: KHMan <keinhong@...>
- Date: Wed, 13 Oct 2010 13:12:29 +0800
On 10/13/2010 10:34 AM, David Manura wrote:
local bits = bit.band(buffer, bit.lshift(1, nbits)-1)
Don't like how this line works at all.
So it gets % 2^32, then bit.lshift(1,32)-1 = 0-1 = -1 ... ewww
Is there any actual technical problem with using this instead?
bit.rshift(0xFFFFFFFF, 32 - nbits)
Assuming we are fixed at 32 bits max, it means that we shift out
unwanted mask bits -- nothing unclear about it. I think
"bit.lshift(1, nbits)-1" is simply something one does in C.
Doesn't mean we must paint in Lua in the same way.
I think compression/decompression routines written in Lua is more
suitable for prototyping work and hence performance is not a
critical issue -- it's not for any real "normal user" apps, is it?
Heavens, before long, someone will lobby for tweaks to run FFT or
DCT in Lua...
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia