Skip to content

Commit

Permalink
Fix shadowed variable in mapillary/opensfm/opensfm/src/map/src/tracks…
Browse files Browse the repository at this point in the history
…_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
  • Loading branch information
r-barnes authored and facebook-github-bot committed Oct 15, 2024
1 parent 03432a8 commit 61c0f12
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions opensfm/src/map/src/tracks_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,15 @@ TracksManager::GetAllPairsConnectivity(
TracksManager TracksManager::MergeTracksManager(
const std::vector<const TracksManager*>& tracks_managers) {
// Some typedefs claryfying the aggregations
using FeatureId = std::pair<ShotId, int>;
using FeatureId_2 = std::pair<ShotId, int>;
using SingleTrackId = std::pair<TrackId, int>;

// Union-find main data
std::vector<std::unique_ptr<UnionFindElement<SingleTrackId>>>
union_find_elements;

// Aggregate tracks be merged using (shot_id, feature_id)
std::unordered_map<FeatureId, std::vector<int>, HashPair>
std::unordered_map<FeatureId_2, std::vector<int>, HashPair>
observations_per_feature_id;
for (int i = 0; i < tracks_managers.size(); ++i) {
const auto& manager = tracks_managers[i];
Expand All @@ -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()) {
Expand Down

0 comments on commit 61c0f12

Please sign in to comment.