Memoize built packages

Packages that successfully built are now stored internally
so they can be quickly accessed on future calls instead of
returning an array of newly built packages on each call.
This commit is contained in:
Kevin Sawicki
2013-01-28 15:42:50 -08:00
parent fa8ca1193f
commit 4fe021bb61
2 changed files with 4 additions and 1 deletions

View File

@@ -25,7 +25,9 @@ _.extend atom,
new LoadTextMatePackagesTask(asyncTextMatePackages).start()
getPackages: ->
@getPackageNames().map((name) -> Package.build(name)).filter (pack) -> pack?
@packages ?= @getPackageNames().map((name) -> Package.build(name))
.filter((pack) -> pack?)
new Array(@packages...)
loadTextMatePackages: ->
pack.load() for pack in @getTextMatePackages()

View File

@@ -250,6 +250,7 @@ describe "Snippets extension", ->
describe "snippet loading", ->
beforeEach ->
atom.packages = null
jasmine.unspy(LoadSnippetsTask.prototype, 'start')
spyOn(LoadSnippetsTask.prototype, 'loadAtomSnippets').andCallFake -> @snippetsLoaded({})
spyOn(LoadSnippetsTask.prototype, 'loadTextMateSnippets').andCallFake -> @snippetsLoaded({})