Optimize perf. on name finding
This commit is contained in:
@@ -28,7 +28,9 @@ module.exports = class Item extends BaseModel
|
|||||||
options.logEvents ?= false
|
options.logEvents ?= false
|
||||||
super attributes, options
|
super attributes, options
|
||||||
|
|
||||||
@on Event.change + ':modVersion', => @slug.mod = @modVersion?.modSlug
|
@on Event.change + ':modVersion', =>
|
||||||
|
@_isCraftable = null
|
||||||
|
@slug.mod = @modVersion?.modSlug
|
||||||
|
|
||||||
# Public Methods ###############################################################################
|
# Public Methods ###############################################################################
|
||||||
|
|
||||||
@@ -42,8 +44,12 @@ module.exports = class Item extends BaseModel
|
|||||||
# Property Methods #############################################################################
|
# Property Methods #############################################################################
|
||||||
|
|
||||||
getIsCraftable: ->
|
getIsCraftable: ->
|
||||||
return false unless @modVersion?
|
if not @_isCraftable?
|
||||||
return @modVersion.hasRecipes @slug
|
@_isCraftable = false
|
||||||
|
if @modVersion?
|
||||||
|
@_isCraftable = @modVersion.hasRecipes @slug
|
||||||
|
|
||||||
|
return @_isCraftable
|
||||||
|
|
||||||
Object.defineProperties @prototype,
|
Object.defineProperties @prototype,
|
||||||
isCraftable: {get:@prototype.getIsCraftable}
|
isCraftable: {get:@prototype.getIsCraftable}
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ module.exports = class NameFinder
|
|||||||
mod.eachName (name, itemSlug)=>
|
mod.eachName (name, itemSlug)=>
|
||||||
return if nameMap[name]?
|
return if nameMap[name]?
|
||||||
|
|
||||||
item = mod.findItem itemSlug
|
|
||||||
if not @includeGatherable
|
if not @includeGatherable
|
||||||
|
item = mod.findItem itemSlug
|
||||||
return unless item? and item.isCraftable
|
return unless item? and item.isCraftable
|
||||||
|
|
||||||
scanName = "#{mod.name} : #{name}"
|
scanName = "#{mod.name} : #{name}"
|
||||||
|
|||||||
Reference in New Issue
Block a user