Skip to content
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

Merged
merged 4 commits into from
May 11, 2021

Conversation

ueqri
Copy link
Contributor

@ueqri ueqri commented Apr 29, 2021

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. 😀

@kunaltyagi
Copy link
Member

use range-based for with const auto reference to gain more performance

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())
Copy link
Member

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;
}

Copy link
Contributor Author

@ueqri ueqri Apr 30, 2021

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:?

@ueqri
Copy link
Contributor Author

ueqri commented Apr 30, 2021

Thanks for your kind reviews! 😀

Any benchmarks for the perf increase?

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.

Copy link
Member

@mvieth mvieth left a 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.

mvieth
mvieth previously approved these changes Apr 30, 2021
@mvieth
Copy link
Member

mvieth commented May 11, 2021

@kunaltyagi Would you like to take another look at this or can it be merged?

@kunaltyagi kunaltyagi merged commit 77c27c3 into PointCloudLibrary:master May 11, 2021
mvieth pushed a commit to mvieth/pcl that referenced this pull request Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants