-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bitops #69
Add bitops #69
Conversation
Currently only bit.band is needed. For LuaJIT: use builtin bit.band For Lua 5.1, 5.2: use bit.band from luabitop if available For Lua 5.3, 5.4: use builtin & operator
Wouldn't it be simpler and easier to just specify luabitop as a LuaRocks dependency and use that on all versions (including LuaJIT)? Personally, I'd like to try and get rid of the Makefile in the future; LuaRocks should support doing almost everything the Makefile does. |
|
Oh, hmm, that's annoying. I'm not aware of any way to specify dependencies based on version, unfortunately. |
Perhaps we could use https://luarocks.org/modules/siffiejoe/bit32 instead? |
It looks like that would work. For LuaJIT it's much slower (by a factor of roughly 40 in my tests) though than the builtin |
Did you benchmark |
I benchmarked |
I'd benchmark the latter before eliminating bit32 as underperformant; in the grand scheme of things, it's the |
In case the |
luaffi-tkl
, which is used on Lua 5.x to replace the LuaJIT builtinffi
module, has dropped shipping itsbit
-module (which only worked on Lua >= 5.3). This PR replaces thebit
-module viabitops.lua
. Only the bitwise and on two arguments is needed.For LuaJIT: use builtin bit.band
For Lua 5.1, 5.2: use bit.band from luabitop if available
For Lua 5.3, 5.4: use builtin & operator
On Lua 5.1, 5.2, which are newly supported,
luabitop
becomes a dependency.