minetest-mods / mesecons

Mod for Minetest that adds digital circuitry [=Minecraft redstone]
https://mesecons.net
Other
211 stars 121 forks source link

Inefficient use of pairs(minetest.registered_nodes) #643

Closed BeverlyCode closed 1 year ago

BeverlyCode commented 1 year ago

https://github.com/minetest-mods/mesecons/blob/master/mesecons/internal.lua#L384

Correct me if I am wrong, but would this function not be faster if that iteration of registered_nodes was output to a smaller array and that the smaller array was used for real-time iteration.

I have't looked at the code in much detail but it seems find_light_update_conductors() is called fairly often in real-time and that any iteration of registered_nodes is best done at register_on_mods_loaded and then the list generated is used in real-time.

Just a small thought that could improve the performance of what is known to be one of the lesser performant mods to run.

sfan5 commented 1 year ago

The function in question only performs the calculations once to fill in a file-local variable with the results.