From 060caad1046b4548ed2d9c90f3d575f3d68cd02c Mon Sep 17 00:00:00 2001 From: Paul Ouellette Date: Mon, 14 Jan 2019 22:30:08 -0500 Subject: [PATCH] Refactor and speed up get_item_usages --- init.lua | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/init.lua b/init.lua index c2077e0..de8b851 100644 --- a/init.lua +++ b/init.lua @@ -465,18 +465,12 @@ end local function get_item_usages(item) local usages = {} - for name, def in pairs(reg_items) do - if not (def.groups.not_in_craft_guide == 1 or - def.groups.not_in_creative_inventory == 1) and - get_recipe(name).items and - def.description and def.description ~= "" then - local recipes = recipes_cache[name] - for i = 1, #recipes do - local recipe = recipes[i] - if item_in_recipe(item, recipe) then - usages[#usages + 1] = recipe - end + for _, recipes in pairs(recipes_cache) do + for i = 1, #recipes do + local recipe = recipes[i] + if item_in_recipe(item, recipe) then + usages[#usages + 1] = recipe end end end