Skip to content

Commit

Permalink
Merge pull request #16724 from IzzatN/use-set-here
Browse files Browse the repository at this point in the history
using Set for storing application instances
  • Loading branch information
rwjblue authored Jun 7, 2018
2 parents f0e52ca + a739ed4 commit ef2b440
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/@ember/application/lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ const Application = Engine.extend({
// the Application's own `boot` method.
this._readinessDeferrals = 1;
this._booted = false;
this._applicationInstances = [];
this._applicationInstances = new Set();

this.autoboot = this._globalsMode = !!this.autoboot;

Expand Down Expand Up @@ -412,7 +412,7 @@ const Application = Engine.extend({
@method _watchInstance
*/
_watchInstance(instance) {
this._applicationInstances.push(instance);
this._applicationInstances.add(instance);
},

/**
Expand All @@ -423,10 +423,7 @@ const Application = Engine.extend({
@method _unwatchInstance
*/
_unwatchInstance(instance) {
let index = this._applicationInstances.indexOf(instance);
if (index > -1) {
this._applicationInstances.splice(index, 1);
}
return this._applicationInstances.delete(instance);
},

/**
Expand Down Expand Up @@ -843,9 +840,9 @@ const Application = Engine.extend({
_loaded.application = undefined;
}

if (this._applicationInstances.length) {
if (this._applicationInstances.size) {
this._applicationInstances.forEach(i => i.destroy());
this._applicationInstances.length = 0;
this._applicationInstances.clear();
}
},

Expand Down

0 comments on commit ef2b440

Please sign in to comment.