-
Notifications
You must be signed in to change notification settings - Fork 20
Refactors, performance improvements, and fixes #54
Conversation
init.lua
Outdated
@@ -986,3 +933,36 @@ for x = 1, 6 do | |||
}) | |||
end | |||
]] | |||
|
|||
minetest.register_on_mods_loaded(function() |
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.
This will cause an error on the latest stable build (0.4.17.1), since it's a 5.0.0-dev feature.
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.
register_on_mods_loaded
is already used elsewhere and the currently released version is 5.0-only. Also this part will probably be dropped as it's just for testing.
end | ||
|
||
local function get_recipes(output) | ||
local function cache_recipes(output) | ||
local recipes = mt.get_all_craft_recipes(output) or {} |
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.
Couldn't you make use of already existing entries in recipes_cache
to skip this lookup?
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.
That's the function that adds an item's recipes to the cache and it's only called once per item in get_init_items
.
And refactor lots of related stuff
Check craft list, don't add duplicates, and only add registered items
Merged, thanks. |
Benchmark in dreambuilder:
master:
PR:
There's no significant difference in the performance of
get_init_items
,get_item_usages("default:stick")
is ~92% faster, andget_progressive_items
is ~54% faster.To test, the benchmark commit can be cherry-picked from my master branch.
Fuels are cached because
get_craft_result
is very slow (try commenting outcache_fuel
inget_init_items
).Also fixes shapeless icon not showing and the wrong tooltip being shown before that.
Sorry it's so big.