From ec6b1a04095c4e74fcf6cd265b66037a875dc50e Mon Sep 17 00:00:00 2001 From: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> Date: Tue, 21 Nov 2023 10:38:19 +0900 Subject: [PATCH] perf(image_projection_based_fusion): replace std::bitset (#5603) --- .../src/pointpainting_fusion/voxel_generator.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/perception/image_projection_based_fusion/src/pointpainting_fusion/voxel_generator.cpp b/perception/image_projection_based_fusion/src/pointpainting_fusion/voxel_generator.cpp index f462b9b0ba17a..f1ba163ee69b9 100755 --- a/perception/image_projection_based_fusion/src/pointpainting_fusion/voxel_generator.cpp +++ b/perception/image_projection_based_fusion/src/pointpainting_fusion/voxel_generator.cpp @@ -60,9 +60,13 @@ std::size_t VoxelGenerator::pointsToVoxels( point[2] = point_current.z(); point[3] = time_lag; // decode the class value back to one-hot binary and assign it to point - for (std::size_t i = 1; i <= config_.class_size_; i++) { - auto decode = std::bitset<8>(*class_iter).to_string(); - point[3 + i] = decode[-i] == 1 ? 1 : 0; + std::fill(point.begin() + 4, point.end(), 0); + auto class_value = static_cast(*class_iter); + auto iter = point.begin() + 4; + while (class_value > 0) { + *iter = class_value % 2; + class_value /= 2; + ++iter; } out_of_range = false;