-
-
Notifications
You must be signed in to change notification settings - Fork 24
Remove unnecessary allocations from subdivide_triangles
#82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
I don't like the manual loop here. Something like: let next_level: Vec<_> = queue.into_iter() Would be better. It'd also be nice to have a function-level test submitted with the change, verifying that the changed function works. |
That would get rid of the pre-allocation, I have benchmarked
I will make a test and test it on the original and this patch |
Supposedly, collect is smart enough to catch the size hint from further up the chain and allocate only once. As would the following: let mut next_level = Vec::with_capacity(queue.len() * 4); Iterators are far easier to multithread with rayon's par_iter so that's my preference. extend, like the iterator, is harder to screw up than the for loop, so it's next in my preference. IOW, I'm more worried about the code being correct and robust to future changes than squeezing every last ounce of single-threaded performance out of it. |
extend for
In this case
Fair |
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review by RecurseML
🔍 Review performed on 1ba9354..857ed77
✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (1)
• src/mesh/polygon.rs
No description provided.