-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Use range-based for & std::find
to modernize codes in segmentation
#4738
Use range-based for & std::find
to modernize codes in segmentation
#4738
Conversation
Any benchmarks for the perf increase? |
} | ||
if (segment_was_found) | ||
const auto it = std::find (i_segment.indices.cbegin (), i_segment.indices.cend (), index); | ||
if (it != i_segment.indices.cend()) |
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.
Perhaps, we can rewrite the condition to exit early
for(loop) {
const auto it = find();
if (it == cend) { continue; }
// rest of logic
break;
}
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.
Using if (it == cend) { continue; }
is more explicit, but could we just stay on the current to make it concise:blush:?
Thanks for your kind reviews! 😀
Sorry, I've not done the perf, I just suppose that using references instead of copies will produce more efficiency. The changes are a bit scattered(not focused on a certain function), so I'm a tad tentative about the benchmarks of this PR. BTW: I'm quite interested in the benchmark jobs of our community. I find that the benchmark of pcl is in progress, #3860, #4718. So I was wondering if there are some plans or small pieces I can work for it. Since I have some experiences on clustering and high-performance computing, I think I am competent for the jobs. |
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.
Just some minor things, else it looks good.
segmentation/include/pcl/segmentation/impl/unary_classifier.hpp
Outdated
Show resolved
Hide resolved
segmentation/include/pcl/segmentation/impl/region_growing_rgb.hpp
Outdated
Show resolved
Hide resolved
segmentation/include/pcl/segmentation/impl/unary_classifier.hpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Lars Glud <[email protected]>
@kunaltyagi Would you like to take another look at this or can it be merged? |
PointCloudLibrary#4738) Co-authored-by: Lars Glud <[email protected]>
std::find
to improve code readability, solved issue in Use better for-loops #4599 (comment)The changes are only in
segmentation
directory, as a small piece of modernization work. I'd be glad to continue working on this PR if needed. 😀