Skip to content

Commit

Permalink
Simplify algorithm; we already have list of computed deps in effect l…
Browse files Browse the repository at this point in the history
…ist.
  • Loading branch information
kevinpschaaf committed Jul 8, 2019
1 parent 567e464 commit 064d0ef
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,30 +581,20 @@ function getComputedOrder(inst) {
function dependencyCounts(inst) {
const infoForComputed = inst[COMPUTE_INFO];
const counts = {};
const computedDeps = inst[TYPES.COMPUTE];
const ready = [];
let total = 0;
// Count dependencies for each computed property
for (let p in infoForComputed) {
const info = infoForComputed[p];
// Be sure to add the method name itself in case of "dynamic functions"
total += counts[p] =
info.args.filter(a => !a.literal).length + (info.dynamicFn ? 1 : 0);
// Add any dependencies that are not themselves computed to the ready queue
info.args.forEach(arg => {
const dep = arg.rootProperty;
// Putting a count of 0 in for ready deps is used for de-duping
if (dep && !infoForComputed[dep] && !(dep in counts)) {
counts[dep] = 0;
ready.push(dep);
}
});
// Add the method name to the ready queue if "dynamic function"
if (info.dynamicFn) {
const dep = info.methodName;
// Putting a count of 0 in for ready deps is used for de-duping
if (dep && !infoForComputed[dep] && !(dep in counts)) {
counts[dep] = 0;
ready.push(dep);
}
}
// Build list of ready properties (that aren't themselves computed)
for (let p in computedDeps) {
if (!infoForComputed[p]) {
ready.push(p);
}
}
return {counts, ready, total};
Expand Down

0 comments on commit 064d0ef

Please sign in to comment.