Skip to content

Commit

Permalink
Merge pull request #15931 from bekzod/property-events-with-map-set
Browse files Browse the repository at this point in the history
utilize `Map` and `Set` in `property_events`
  • Loading branch information
rwjblue authored Jan 28, 2018
2 parents 4065696 + 56183a1 commit 51d897d
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions packages/ember-metal/lib/property_events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { guidFor, symbol } from 'ember-utils';
import { symbol } from 'ember-utils';
import {
descriptorFor,
peekMeta
Expand Down Expand Up @@ -115,16 +115,16 @@ function notifyPropertyChange(obj, keyName, _meta) {
}
}

let DID_SEEN;
let DID_SEEN = null;

// called whenever a property has just changed to update dependent keys
function dependentKeysDidChange(obj, depKey, meta) {
if (meta.isSourceDestroying() || !meta.hasDeps(depKey)) { return; }
let seen = DID_SEEN;
let top = !seen;
let top = seen === null;

if (top) {
seen = DID_SEEN = {};
seen = DID_SEEN = new Map();
}

iterDeps(notifyPropertyChange, obj, depKey, seen, meta);
Expand All @@ -135,20 +135,16 @@ function dependentKeysDidChange(obj, depKey, meta) {
}

function iterDeps(method, obj, depKey, seen, meta) {
let possibleDesc;
let guid = guidFor(obj);
let current = seen[guid];

if (!current) {
current = seen[guid] = {};
}
let current = seen.get(obj);

if (current[depKey]) {
return;
if (current === undefined) {
current = new Set();
seen.set(obj, current);
}

current[depKey] = true;
if (current.has(depKey)) { return; }

let possibleDesc;
meta.forEachInDeps(depKey, (key, value) => {
if (!value) { return; }

Expand Down

0 comments on commit 51d897d

Please sign in to comment.