Permalink
Browse files

Cache the object descriptors

_propertyList used to be called a ton on new layer creation, but now we chache it until a new property descriptor is added.
  • Loading branch information...
koenbok committed Aug 29, 2017
1 parent 1d564f1 commit 76592c1281c64c99c89552e8702a8a7766f62ab8
Showing with 12 additions and 0 deletions.
  1. +12 −0 framer/BaseClass.coffee
View
@@ -8,6 +8,7 @@ CounterKey = "_ObjectCounter"
DefinedPropertiesValuesKey = "_DefinedPropertiesValuesKey"
ObjectDescriptors = []
ObjectDescriptorsChanged = true
# Theoretically this should be an array per class, but as long as we don't do weird stuff
# like depending properties of subclasses in a different order then superclasses this will work
@@ -55,6 +56,8 @@ class exports.BaseClass extends EventEmitter
return if _.startsWith(propertyName, "_")
ObjectDescriptors.push([@, propertyName, descriptor])
ObjectDescriptorsChanged = true
# Only retain options that are importable, exportable or both:
if descriptor.exportable or descriptor.importable
if descriptor.depends
@@ -100,7 +103,16 @@ class exports.BaseClass extends EventEmitter
@_propertyList()[k]["default"]
_propertyList: ->
if not @_propertyListCache or ObjectDescriptorsChanged
@_propertyListCache = @__propertyList()
ObjectDescriptorsChanged = false
return @_propertyListCache
__propertyList: ->
result = {}
for k in ObjectDescriptors
[Class, name, descriptor] = k
if @ instanceof Class

0 comments on commit 76592c1

Please sign in to comment.