Skip to content

Commit af7b2d5

Browse files
DIlkhush00mvieth
authored andcommitted
pre-allocating the container capacity before the loop
1 parent da62355 commit af7b2d5

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

common/src/io.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ pcl::concatenateFields (const pcl::PCLPointCloud2 &cloud1,
102102
//by offset so that we can compute sizes correctly. There is no
103103
//guarantee that the fields are in the correct order when they come in
104104
std::vector<const pcl::PCLPointField*> cloud1_fields_sorted;
105+
cloud1_fields_sorted.reserve(cloud1.fields.size());
106+
105107
for (const auto &field : cloud1.fields)
106108
cloud1_fields_sorted.push_back (&field);
107109

visualization/include/pcl/visualization/area_picking_event.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ namespace pcl
8181
getCloudNames () const
8282
{
8383
std::vector<std::string> names;
84+
names.reserve(cloud_indices_.size());
85+
8486
for (const auto& i : cloud_indices_)
8587
names.push_back (i.first);
8688
return names;

0 commit comments

Comments
 (0)