Improve perf. of mod version parsing
Add a SimpleStack model which is identical to the regular Stack model except for not being a Backbone.Model subclass. Since so many stacks are created during mod version parsing, this makes about a 50% difference in performance during loading.
This commit is contained in:
@@ -10,7 +10,7 @@ Item = require '../item'
|
|||||||
ItemSlug = require '../item_slug'
|
ItemSlug = require '../item_slug'
|
||||||
ModVersion = require '../mod_version'
|
ModVersion = require '../mod_version'
|
||||||
Recipe = require '../recipe'
|
Recipe = require '../recipe'
|
||||||
Stack = require '../stack'
|
Stack = require '../simple_stack'
|
||||||
StringBuilder = require '../string_builder'
|
StringBuilder = require '../string_builder'
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
###
|
||||||
|
Crafting Guide - simple_stack.coffee
|
||||||
|
|
||||||
|
Copyright (c) 2014-2015 by Redwood Labs
|
||||||
|
All rights reserved.
|
||||||
|
###
|
||||||
|
|
||||||
|
########################################################################################################################
|
||||||
|
|
||||||
|
module.exports = class Stack
|
||||||
|
|
||||||
|
constructor: (attributes={}, options={})->
|
||||||
|
if not attributes.itemSlug? then throw new Error 'attributes.itemSlug is required'
|
||||||
|
attributes.quantity ?= 1
|
||||||
|
|
||||||
|
@itemSlug = attributes.itemSlug
|
||||||
|
@quantity = attributes.quantity
|
||||||
|
|
||||||
|
# Object Overrides #############################################################################
|
||||||
|
|
||||||
|
toString: ->
|
||||||
|
return "#{@quantity} #{@itemSlug}"
|
||||||
Reference in New Issue
Block a user