From 61c0f12c580a305ce8a016827c7a3974059538e9 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Tue, 15 Oct 2024 13:58:42 -0700 Subject: [PATCH] Fix shadowed variable in mapillary/opensfm/opensfm/src/map/src/tracks_manager.cc Summary: Our upcoming compiler upgrade will require us not to have shadowed variables. Such variables have a _high_ bug rate and reduce readability, so we would like to avoid them even if the compiler was not forcing us to do so. This codemod attempts to fix an instance of a shadowed variable. Please review with care: if it's failed the result will be a silent bug. **What's a shadowed variable?** Shadowed variables are variables in an inner scope with the same name as another variable in an outer scope. Having the same name for both variables might be semantically correct, but it can make the code confusing to read! It can also hide subtle bugs. This diff fixes such an issue by renaming the variable. - If you approve of this diff, please use the "Accept & Ship" button :-) Reviewed By: palmje Differential Revision: D64398698 fbshipit-source-id: e70f61a9337391e8357fff7a8d07c0b927c63b4d --- opensfm/src/map/src/tracks_manager.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opensfm/src/map/src/tracks_manager.cc b/opensfm/src/map/src/tracks_manager.cc index 93272e5dd..89dc64aa4 100644 --- a/opensfm/src/map/src/tracks_manager.cc +++ b/opensfm/src/map/src/tracks_manager.cc @@ -356,7 +356,7 @@ TracksManager::GetAllPairsConnectivity( TracksManager TracksManager::MergeTracksManager( const std::vector& tracks_managers) { // Some typedefs claryfying the aggregations - using FeatureId = std::pair; + using FeatureId_2 = std::pair; using SingleTrackId = std::pair; // Union-find main data @@ -364,7 +364,7 @@ TracksManager TracksManager::MergeTracksManager( union_find_elements; // Aggregate tracks be merged using (shot_id, feature_id) - std::unordered_map, HashPair> + std::unordered_map, HashPair> observations_per_feature_id; for (int i = 0; i < tracks_managers.size(); ++i) { const auto& manager = tracks_managers[i]; @@ -387,7 +387,7 @@ TracksManager TracksManager::MergeTracksManager( return merged; } - // Union-find any two tracks sharing a common FeatureId + // Union-find any two tracks sharing a common FeatureId_2 // For N tracks, make 0 the parent of [1, ... N-1[ for (const auto& tracks_agg : observations_per_feature_id) { if (tracks_agg.second.empty()) {