Memoize load settings and return a clone

Calling this method actual eats up a lot of spec time since
it does an ipc channel sync call.
This commit is contained in:
Kevin Sawicki 2013-10-02 14:08:19 -07:00
parent 9b97433214
commit 5aa83163ad

View File

@ -88,8 +88,12 @@ class Atom
dimensions = defaultDimensions unless dimensions?.width and dimensions?.height
@setDimensions(dimensions)
# Public: Get the load settings for the current window.
#
# Returns an object containing all the load setting key/value pairs.
getLoadSettings: ->
@getCurrentWindow().loadSettings
@loadSettings ?= _.clone(@getCurrentWindow().loadSettings)
_.clone(@loadSettings)
deserializeProject: ->
Project = require './project'
@ -254,7 +258,7 @@ class Atom
if windowStatePath = @getWindowStatePath()
windowState.saveSync(path: windowStatePath)
else
@getLoadSettings().windowState = JSON.stringify(windowState.serialize())
@getCurrentWindow().loadSettings.windowState = JSON.stringify(windowState.serialize())
getWindowState: (keyPath) ->
@windowState ?= @loadWindowState()