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={})->
|
findRecipes: (itemSlug, result=[], options={})->
|
||||||
options.onlyPrimary ?= false
|
options.onlyPrimary ?= false
|
||||||
|
|
||||||
for k, recipe of @_recipes
|
for recipe in _.values @_recipes
|
||||||
if options.onlyPrimary
|
if options.onlyPrimary
|
||||||
if recipe.itemSlug.matches itemSlug
|
if recipe.itemSlug.matches itemSlug
|
||||||
result.push recipe
|
result.push recipe
|
||||||
|
|||||||
@@ -100,11 +100,14 @@ module.exports = class Recipe extends BaseModel
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
produces: (itemSlug)->
|
produces: (itemSlug)->
|
||||||
for stack in @output
|
if not @_produces?
|
||||||
if stack.itemSlug.matches itemSlug
|
@_produces = {}
|
||||||
return true
|
|
||||||
|
|
||||||
return false
|
for stack in @output
|
||||||
|
@_produces[stack.itemSlug.qualified] = true
|
||||||
|
@_produces[stack.itemSlug.item] = true
|
||||||
|
|
||||||
|
return @_produces[itemSlug.qualified]
|
||||||
|
|
||||||
requires: (itemSlug)->
|
requires: (itemSlug)->
|
||||||
for stack in @input
|
for stack in @input
|
||||||
|
|||||||
Reference in New Issue
Block a user