From df3a164f4b06db79bad3c1d6a1198be0f0ac4760 Mon Sep 17 00:00:00 2001 From: neka-nat Date: Fri, 15 Mar 2024 19:41:16 +0900 Subject: [PATCH] emplace_back --- examples/cpp/kinematics.cpp | 2 +- src/cupoch/geometry/image.cu | 4 ++-- src/cupoch/geometry/image_factory.cu | 6 +++--- src/cupoch/geometry/rgbdimage.cu | 6 +++--- src/cupoch/kinematics/kinematic_chain.cpp | 12 ++++++------ src/cupoch/utility/helper.cpp | 2 +- src/cupoch/visualization/visualizer/visualizer.cpp | 8 ++++---- .../visualization/visualizer/visualizer_renderer.cpp | 2 +- src/python/cupoch_pybind/docstring.cpp | 10 +++++----- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/examples/cpp/kinematics.cpp b/examples/cpp/kinematics.cpp index b7611eaf..5cd671bb 100644 --- a/examples/cpp/kinematics.cpp +++ b/examples/cpp/kinematics.cpp @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) { auto poses = kin.ForwardKinematics(); auto meshes = kin.GetTransformedVisualGeometryMap(poses); std::vector> geoms; - for (const auto& m: meshes) { geoms.push_back(m.second); }; + for (const auto& m: meshes) { geoms.emplace_back(m.second); }; visualization::DrawGeometries(geoms); return 0; } \ No newline at end of file diff --git a/src/cupoch/geometry/image.cu b/src/cupoch/geometry/image.cu index da82c4fc..7d4680a8 100644 --- a/src/cupoch/geometry/image.cu +++ b/src/cupoch/geometry/image.cu @@ -536,7 +536,7 @@ ImagePyramid Image::FilterPyramid(const ImagePyramid &input, std::vector> output; for (size_t i = 0; i < input.size(); i++) { auto layer_filtered = input[i]->Filter(type); - output.push_back(layer_filtered); + output.emplace_back(layer_filtered); } return output; } @@ -549,7 +549,7 @@ ImagePyramid Image::BilateralFilterPyramid(const ImagePyramid &input, for (size_t i = 0; i < input.size(); i++) { auto layer_filtered = input[i]->BilateralFilter(diameter, sigma_color, sigma_space); - output.push_back(layer_filtered); + output.emplace_back(layer_filtered); } return output; } diff --git a/src/cupoch/geometry/image_factory.cu b/src/cupoch/geometry/image_factory.cu index d87e886e..b55370a1 100644 --- a/src/cupoch/geometry/image_factory.cu +++ b/src/cupoch/geometry/image_factory.cu @@ -260,17 +260,17 @@ ImagePyramid Image::CreatePyramid(size_t num_of_levels, if (i == 0) { std::shared_ptr input_copy_ptr = std::make_shared(); *input_copy_ptr = *this; - pyramid_image.push_back(input_copy_ptr); + pyramid_image.emplace_back(input_copy_ptr); } else { if (with_gaussian_filter && num_of_channels_ == 1) { // https://en.wikipedia.org/wiki/Pyramid_(image_processing) auto level_b = pyramid_image[i - 1]->Filter( Image::FilterType::Gaussian3); auto level_bd = level_b->Downsample(); - pyramid_image.push_back(level_bd); + pyramid_image.emplace_back(level_bd); } else { auto level_d = pyramid_image[i - 1]->Downsample(); - pyramid_image.push_back(level_d); + pyramid_image.emplace_back(level_d); } } } diff --git a/src/cupoch/geometry/rgbdimage.cu b/src/cupoch/geometry/rgbdimage.cu index 50e01126..f3a40c7f 100644 --- a/src/cupoch/geometry/rgbdimage.cu +++ b/src/cupoch/geometry/rgbdimage.cu @@ -69,7 +69,7 @@ RGBDImagePyramid RGBDImage::FilterPyramid( auto depth_level_filtered = depth_level.Filter(type); auto rgbd_image_level_filtered = std::make_shared( RGBDImage(*color_level_filtered, *depth_level_filtered)); - rgbd_image_pyramid_filtered.push_back(rgbd_image_level_filtered); + rgbd_image_pyramid_filtered.emplace_back(rgbd_image_level_filtered); } return rgbd_image_pyramid_filtered; } @@ -87,7 +87,7 @@ RGBDImagePyramid RGBDImage::BilateralFilterPyramidDepth( depth_level.BilateralFilter(diameter, sigma_depth, sigma_space); auto rgbd_image_level_filtered = std::make_shared(RGBDImage( rgbd_image_pyramid[level]->color_, *depth_level_filtered)); - rgbd_image_pyramid_filtered.push_back( + rgbd_image_pyramid_filtered.emplace_back( std::move(rgbd_image_level_filtered)); } return rgbd_image_pyramid_filtered; @@ -106,7 +106,7 @@ RGBDImagePyramid RGBDImage::CreatePyramid( for (size_t level = 0; level < num_of_levels; level++) { auto rgbd_image_level = std::make_shared( RGBDImage(*color_pyramid[level], *depth_pyramid[level])); - rgbd_image_pyramid.push_back(rgbd_image_level); + rgbd_image_pyramid.emplace_back(rgbd_image_level); } return rgbd_image_pyramid; } diff --git a/src/cupoch/kinematics/kinematic_chain.cpp b/src/cupoch/kinematics/kinematic_chain.cpp index 81685ee6..7b5bde49 100644 --- a/src/cupoch/kinematics/kinematic_chain.cpp +++ b/src/cupoch/kinematics/kinematic_chain.cpp @@ -61,7 +61,7 @@ KinematicChain& KinematicChain::BuildFromURDF(const std::string& filename) { for (std::map::const_iterator itr = jmap.begin(); itr != jmap.end(); ++itr) { - joints.push_back(itr->second); + joints.emplace_back(itr->second); } int n_joints = joints.size(); std::vector has_root(n_joints, true); @@ -84,11 +84,11 @@ KinematicChain& KinematicChain::BuildFromURDF(const std::string& filename) { root_.joint_ = Joint("root_joint"); std::vector collisions; for (const auto& col : root_link->collision_array) { - collisions.push_back(ConvertCollision(col, root_path_)); + collisions.emplace_back(ConvertCollision(col, root_path_)); } std::vector visuals; for (const auto& vis : root_link->visual_array) { - visuals.push_back(ConvertVisual(vis, root_path_)); + visuals.emplace_back(ConvertVisual(vis, root_path_)); } root_.link_ = Link(root_link->name, collisions, visuals); link_map_[root_.link_.name_] = &(root_.link_); @@ -137,16 +137,16 @@ std::vector> KinematicChain::BuildChainRecurse( auto link = lmap.at(joint->child_link_name); std::vector collisions; for (const auto& col : link->collision_array) { - collisions.push_back(ConvertCollision(col, root_path_)); + collisions.emplace_back(ConvertCollision(col, root_path_)); } std::vector visuals; for (const auto& vis : link->visual_array) { - visuals.push_back(ConvertVisual(vis, root_path_)); + visuals.emplace_back(ConvertVisual(vis, root_path_)); } child->link_ = Link(link->name, collisions, visuals); link_map_[child->link_.name_] = &(child->link_); child->children_ = BuildChainRecurse(*child, lmap, joints); - children.push_back(child); + children.emplace_back(child); } } return children; diff --git a/src/cupoch/utility/helper.cpp b/src/cupoch/utility/helper.cpp index ac76a8ee..442b9b8b 100644 --- a/src/cupoch/utility/helper.cpp +++ b/src/cupoch/utility/helper.cpp @@ -34,7 +34,7 @@ void cupoch::utility::SplitString(std::vector &tokens, pos = str.find_first_of(delimiters, last_pos); new_pos = (pos == std::string::npos ? str.length() : pos); if (new_pos != last_pos || !trim_empty_str) { - tokens.push_back(str.substr(last_pos, new_pos - last_pos)); + tokens.emplace_back(str.substr(last_pos, new_pos - last_pos)); } last_pos = new_pos + 1; } diff --git a/src/cupoch/visualization/visualizer/visualizer.cpp b/src/cupoch/visualization/visualizer/visualizer.cpp index 7ad2d66f..11c6bd8b 100644 --- a/src/cupoch/visualization/visualizer/visualizer.cpp +++ b/src/cupoch/visualization/visualizer/visualizer.cpp @@ -247,10 +247,10 @@ void Visualizer::BuildUtilities() { grid_line_ptr_) == false) { return; } - utility_ptrs_.push_back(coordinate_frame_mesh_ptr_); - utility_renderer_ptrs_.push_back(coordinate_frame_mesh_renderer_ptr_); - utility_ptrs_.push_back(grid_line_ptr_); - utility_renderer_ptrs_.push_back(grid_line_renderer_ptr_); + utility_ptrs_.emplace_back(coordinate_frame_mesh_ptr_); + utility_renderer_ptrs_.emplace_back(coordinate_frame_mesh_renderer_ptr_); + utility_ptrs_.emplace_back(grid_line_ptr_); + utility_renderer_ptrs_.emplace_back(grid_line_renderer_ptr_); } void Visualizer::Run() { diff --git a/src/cupoch/visualization/visualizer/visualizer_renderer.cpp b/src/cupoch/visualization/visualizer/visualizer_renderer.cpp index e71a8a4c..943cb1fa 100644 --- a/src/cupoch/visualization/visualizer/visualizer_renderer.cpp +++ b/src/cupoch/visualization/visualizer/visualizer_renderer.cpp @@ -113,7 +113,7 @@ void Visualizer::CopyViewStatusToClipboard() { utility::LogError("Something is wrong copying view status."); } ViewTrajectory trajectory; - trajectory.view_status_.push_back(current_status); + trajectory.view_status_.emplace_back(current_status); std::string clipboard_string; if (io::WriteIJsonConvertibleToJSONString(clipboard_string, trajectory) == false) { diff --git a/src/python/cupoch_pybind/docstring.cpp b/src/python/cupoch_pybind/docstring.cpp index 2d57c447..7d0d1126 100644 --- a/src/python/cupoch_pybind/docstring.cpp +++ b/src/python/cupoch_pybind/docstring.cpp @@ -169,7 +169,7 @@ void FunctionDoc::ParseArguments() { std::vector argument_tokens = GetArgumentTokens(pybind_doc_); argument_docs_.clear(); for (const std::string& argument_token : argument_tokens) { - argument_docs_.push_back(ParseArgumentToken(argument_token)); + argument_docs_.emplace_back(ParseArgumentToken(argument_token)); } } @@ -348,7 +348,7 @@ std::vector FunctionDoc::GetArgumentTokens( size_t pos = res.position(0) + (start_iter - str.cbegin()); start_iter = res.suffix().first; // Now the pos include ", ", which needs to be removed - argument_start_positions.push_back(pos + 2); + argument_start_positions.emplace_back(pos + 2); } // Get end positions (non-inclusive) @@ -356,13 +356,13 @@ std::vector FunctionDoc::GetArgumentTokens( // The last argument's end pos is the location of the parenthesis before -> std::vector argument_end_positions; for (size_t i = 0; i + 1 < argument_start_positions.size(); ++i) { - argument_end_positions.push_back(argument_start_positions[i + 1] - 2); + argument_end_positions.emplace_back(argument_start_positions[i + 1] - 2); } std::size_t arrow_pos = str.rfind(") -> "); if (arrow_pos == std::string::npos) { return {}; } else { - argument_end_positions.push_back(arrow_pos); + argument_end_positions.emplace_back(arrow_pos); } std::vector argument_tokens; @@ -370,7 +370,7 @@ std::vector FunctionDoc::GetArgumentTokens( std::string token = str.substr( argument_start_positions[i], argument_end_positions[i] - argument_start_positions[i]); - argument_tokens.push_back(token); + argument_tokens.emplace_back(token); } return argument_tokens; }