the-teacher / the_sortable_tree

Nested Set + Drag&Drop GUI. Very fast! Best render helper! 2000 nodes/sec. Ready for rails 4
MIT License
558 stars 127 forks source link

Improves render performance during root selection #93

Open cars10 opened 6 years ago

cars10 commented 6 years ago

In :199 we select the roots by loading all values of opts[:boost][c.to_s] where c.to_s is an existing parent. If it does not exist as parent we get nil and throw that out with .compact in the end.

But we can use & beforehand to only loop through the ids that are present as parent, thus having fewer loops and removing the need to run .compact.

the-teacher commented 6 years ago

@cars10 Hey, your explanation sounds clear and I feel that your change has to improve this part of the code. But I'm afraid to break something if I merge this PR. Usually I use manual testing to be sure that everything is ok. Right now I don't have enough time to check it carefully.

I'm sorry for the delay. I like what you have done and I'll try to find time to check and merge it. Sorry, currently I don't work with ruby/rails too much to do it quickly.