Closed thiagopromano closed 1 year ago
Very interesting, That makes a lot of sense - shift is definitely slower than pop.
Changing that shift
to a pop
would make this a depth first search instead of a breadth first one... a stretch but technically a breaking change since we advertise this service as a doing a breadth first search (and even call it Bfs
🤦♂️ ).
I'd be super open to a PR. Though we couldn't keep calling the service Bfs
if it's doing DFS and It would be nice to not have to bump the major version if possible.
Hi!
I was checking your project to build a huge tree, over 50k nodes.
I implemented both tips on the Readme.md to increase performance and noticed a huge boost.
Only then I noticed a big lag when selecting and deselecting leaf nodes, I when profiled the .js I found the culprit:
Using Chrome 67 the code spent a long time on line 806 of the dist file:
next = queue.shift();
If I used
next = queue.pop();
the code went much much faster! The tree was being built exactly the same and everything seems to work fine.Therefore I suggest replacing the following line with
next = queue.pop()
:https://github.com/iVantage/angular-ivh-treeview/blob/589b6b2525b215eeeba77e930b4bbb5e3aa0502d/src/scripts/services/ivh-treeview-bfs.js#L63
If you want I can create a Pull Request.
Best Regards.