From 5aa83163ad828869c80469878357d64c5da36633 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 2 Oct 2013 14:08:19 -0700 Subject: [PATCH] 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. --- src/atom.coffee | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/atom.coffee b/src/atom.coffee index 3206081c3..c4d9cc18a 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -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()