Optimize perf. of crafting algo. (55% savings)
This commit is contained in:
@@ -134,7 +134,7 @@ module.exports = class ModVersion extends BaseModel
|
||||
findRecipes: (itemSlug, result=[], options={})->
|
||||
options.onlyPrimary ?= false
|
||||
|
||||
for k, recipe of @_recipes
|
||||
for recipe in _.values @_recipes
|
||||
if options.onlyPrimary
|
||||
if recipe.itemSlug.matches itemSlug
|
||||
result.push recipe
|
||||
|
||||
@@ -100,11 +100,14 @@ module.exports = class Recipe extends BaseModel
|
||||
return 0
|
||||
|
||||
produces: (itemSlug)->
|
||||
for stack in @output
|
||||
if stack.itemSlug.matches itemSlug
|
||||
return true
|
||||
if not @_produces?
|
||||
@_produces = {}
|
||||
|
||||
return false
|
||||
for stack in @output
|
||||
@_produces[stack.itemSlug.qualified] = true
|
||||
@_produces[stack.itemSlug.item] = true
|
||||
|
||||
return @_produces[itemSlug.qualified]
|
||||
|
||||
requires: (itemSlug)->
|
||||
for stack in @input
|
||||
|
||||
Reference in New Issue
Block a user