Browse Source

🐞 fix(FDL-2946): 提升大数据量下inittree的速度

master
iapyang 2 years ago
parent
commit
9ac554bb4c
  1. 13
      src/core/structure/tree.js

13
src/core/structure/tree.js

@ -30,20 +30,23 @@
initTree: function (nodes) {
var self = this;
this.clear();
var queue = [];
var queue = new Set();
BI.each(nodes, function (i, node) {
var n = new BI.Node(node);
n.set("data", node);
self.addNode(n);
queue.push(n);
queue.add(n);
});
while (!BI.isEmpty(queue)) {
var parent = queue.shift();
while (queue.size > 0) {
var [parent] = queue;
queue.delete(parent);
var node = parent.get("data");
BI.each(node.children, function (i, child) {
var n = new BI.Node(child);
n.set("data", child);
queue.push(n);
queue.add(n);
self.addNode(parent, n);
});
}

Loading…
Cancel
Save