Skip to content

Commit

Permalink
pre-allocating the container capacity before the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
DIlkhush00 authored and mvieth committed Sep 6, 2024
1 parent da62355 commit af7b2d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/src/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ pcl::concatenateFields (const pcl::PCLPointCloud2 &cloud1,
//by offset so that we can compute sizes correctly. There is no
//guarantee that the fields are in the correct order when they come in
std::vector<const pcl::PCLPointField*> cloud1_fields_sorted;
cloud1_fields_sorted.reserve(cloud1.fields.size());

for (const auto &field : cloud1.fields)
cloud1_fields_sorted.push_back (&field);

Expand Down
2 changes: 2 additions & 0 deletions visualization/include/pcl/visualization/area_picking_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ namespace pcl
getCloudNames () const
{
std::vector<std::string> names;
names.reserve(cloud_indices_.size());

for (const auto& i : cloud_indices_)
names.push_back (i.first);
return names;
Expand Down

0 comments on commit af7b2d5

Please sign in to comment.