Skip to content

Commit 028e5a8

Browse files
data store: remove redundant safety check (#1631)
* This was checking whether a node already exists in the tree before creating a new one. * However, the `$index` already serves this function (nodes will be retrieved from the index if they already exist) so this check was redundant. * This reduces the cost of the `createTreeNode` routine when the number of sibling elements is large.
1 parent c8e24f1 commit 028e5a8

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/store/workflows.module.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,7 @@ function update (state, updatedData) {
300300

301301
// create a new tree item
302302
let treeParent
303-
const ret = createTreeNode(state, id, tokens, updatedData)
304-
if (!ret) {
305-
// node already exists, nothing more to do here
306-
return
307-
}
308-
[treeParent, treeItem] = ret
303+
[treeParent, treeItem] = createTreeNode(state, id, tokens, updatedData)
309304

310305
// add the new item to the tree
311306
addChild(treeParent, treeItem)
@@ -418,11 +413,6 @@ function createTreeNode (state, id, tokens, node) {
418413
}
419414
}
420415

421-
if (pointer.children.some(child => child.id === id)) {
422-
// node already in the tree
423-
return
424-
}
425-
426416
const treeNode = {
427417
id,
428418
tokens,

0 commit comments

Comments
 (0)