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
Consolidate API object code #12728
Consolidate API object code #12728
Conversation
19f1322
to
6f56af2
Compare
Hmm, not sure if I like the closure/upvalue solution even if it is a bit faster. But we'll get to this when the other PR is done. |
ba21ee6
to
dc9642c
Compare
dc9642c
to
f33f758
Compare
I probably won't rebase this unless the concept is approved. |
f33f758
to
3ecdffd
Compare
Nevermind, this rebase at least was easy. |
Okay so like I hinted at I'm not a fan of the extra complexity of the upvalue/closure solution and I think we should keep using |
I have changed I should do a benchmark using PUC Lua where a RNG is used in a loop. This is a realistic situation to benchmark method overhead. |
Realistic benchmark using PUC Lua: local rng = PcgRandom(123)
local results = {}
local before = core.get_us_time()
for i = 1, 10000 do
results[i] = rng:next()
end
local after = core.get_us_time()
core.debug("Benchmark:", after - before) Time with |
All that minetest/lib/lua/src/lauxlib.c Lines 124 to 137 in b123305
You could try to store the userdatas in an array table in the registry instead of using a string index. |
Good idea. |
With LuaJIT, the integer index solution seemed like a lot of complexity for no performance gain, perhaps even a small performance loss. I decided to remove the optimizations from this PR altogether. They can be added separately. |
This really should not be micro-optimized, with the numbers from the earlier benchmark the idiomatic solution with |
Probably true. In any case, optimization is no longer a goal of this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if you've tested it reasonably feel free to merge
Co-authored-by: sfan5 <sfan5@live.de>
This PR reduces repetition in the code that implements userdata objects such as
VoxelManip
andSettings
. Overall, it removes over 600 lines of code. It should also decrease the size of the executable, but I haven't measured that.To do
This PR is Ready for Review.
How to test
There are many changes in the PR, and it's possible that some are erroneous. Someone should look through them to make sure this is not the case.