Skip to content

Commit

Permalink
Remove reserve from hot path
Browse files Browse the repository at this point in the history
  • Loading branch information
kunaltyagi committed Sep 24, 2019
1 parent 16f9857 commit 4b153ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/include/pcl/point_cloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ namespace pcl
cloud1.header.stamp = std::max (cloud1.header.stamp, cloud2.header.stamp);

size_t nr_points = cloud1.points.size ();
cloud1.points.reserve (nr_points + cloud2.points.size ());
/* cloud1.points.reserve (nr_points + cloud2.points.size ()); */
cloud1.points.insert (cloud1.points.end (), cloud2.points.begin (), cloud2.points.end ());

cloud1.width = static_cast<uint32_t>(cloud1.points.size ());
Expand Down
2 changes: 1 addition & 1 deletion common/src/PCLPointCloud2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ pcl::PCLPointCloud2::concatenate (pcl::PCLPointCloud2 &cloud1, const pcl::PCLPoi
const auto data1_size = cloud1.data.size ();

// conservative allocation
cloud1.data.reserve (data1_size + cloud2.data.size ());
if (memcpy_possible)
{
cloud1.data.insert (cloud1.data.end (), cloud2.data.begin (), cloud2.data.end ());
return (true);
}
cloud1.data.resize(data1_size + cloud2.data.size ());
for (std::size_t cp = 0; cp < size2; ++cp)
{
for (const auto field_data: valid_fields)
Expand Down

0 comments on commit 4b153ca

Please sign in to comment.