Optimize loops and implement caching improvements - #117
Merged
Conversation
saurabh1002
requested review from
benemer,
mehermvr and
tizianoGuadagnino
as code owners
August 14, 2026 14:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors several core algorithms and data structures in the map closure and ground alignment modules to improve efficiency, clarity, and maintainability. The most significant changes include replacing certain STL algorithms with explicit for-loops for better readability and control, introducing new member variables for keypoint and match management, and adjusting mathematical operations for clarity and performance. Additionally, minor code cleanups and variable type improvements are present.
Algorithm and Loop Refactoring:
std::transform,std::for_each, andstd::transform_reducewith explicit for-loops inGroundAlign.cpp, making the code more readable and easier to debug, especially in functions likeTransformPoints,SampleGroundPoints, and the density map generation logic. [1] [2] [3] [4]DensityMap.cpp, precomputed transformation matrix blocks and resolution inverses to avoid repeated calculations and improve performance in the discretization lambda.Keypoint and Match Management:
orb_keypoints_andself_matches_as member variables inMapClosures, replacing local variables. This ensures consistent state management and reduces allocations across multiple methods. [1] [2] [3] [4] [5]Mathematical and Type Improvements:
const auto&for structured bindings and correcting matrix block usage in density map generation. [1] [2] [3] [4]Data Structure and Utility Updates:
VoxelCenterinVoxelMap.cppfor calculating voxel centers, improving code clarity.map_resolution_tomap_resolution2_(squared) for more accurate spatial resolution representation in the voxel map.Minor Cleanups:
<algorithm>) and made minor const-correctness improvements in function signatures. [1] [2] [3]These changes collectively enhance code clarity, maintainability, and performance, especially in the core map closure and ground alignment routines.