Skip to content

Commit

Permalink
little performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mstdokumaci committed Sep 5, 2019
1 parent f14daac commit 189d63e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/api/subscription/fire.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Leaf } from '../../leaf'

const addParentSubscription = (branch, parent, child, depth, parentList) => {
const addParentSubscription = (branch, parent, child, depth, parentList, stamp) => {
if (branch.subscriptions[parent]) {
if (branch.subscriptions[parent].stamp === stamp) {
return
}

if (branch.subscriptions[parent].keys) {
branch.subscriptions[parent].keys.push([child, depth])
} else {
Expand Down Expand Up @@ -35,7 +39,7 @@ const subscriptions = (branch, id, stamp, depth) => {
if (!branch.parentSubscriptions[depth]) {
branch.parentSubscriptions[depth] = []
}
addParentSubscription(branch, parent, id, 1, branch.parentSubscriptions[depth])
addParentSubscription(branch, parent, id, 1, branch.parentSubscriptions[depth], stamp)
}
}

Expand Down Expand Up @@ -91,7 +95,7 @@ const parentSubscriptions = (branch, id, stamp, keys, parentList) => {
parentList[last] = []
}
const depth = Math.min(...keys.map(key => key[1]))
addParentSubscription(branch, parent, id, depth + 1, parentList[last])
addParentSubscription(branch, parent, id, depth + 1, parentList[last], stamp)
}
}

Expand Down

0 comments on commit 189d63e

Please sign in to comment.