diff --git a/common/src/io.cpp b/common/src/io.cpp index 85d6f27dc3a..8b13e740ab4 100644 --- a/common/src/io.cpp +++ b/common/src/io.cpp @@ -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 cloud1_fields_sorted; + cloud1_fields_sorted.reserve(cloud1.fields.size()); + for (const auto &field : cloud1.fields) cloud1_fields_sorted.push_back (&field); diff --git a/visualization/include/pcl/visualization/area_picking_event.h b/visualization/include/pcl/visualization/area_picking_event.h index 26cb217612f..eba9764da2a 100644 --- a/visualization/include/pcl/visualization/area_picking_event.h +++ b/visualization/include/pcl/visualization/area_picking_event.h @@ -81,6 +81,8 @@ namespace pcl getCloudNames () const { std::vector names; + names.reserve(cloud_indices_.size()); + for (const auto& i : cloud_indices_) names.push_back (i.first); return names;