From 7f5e97e91f1034d3d7b64397d70661d086850d7c Mon Sep 17 00:00:00 2001 From: Alberto Giacalone Date: Mon, 10 Nov 2025 14:14:29 +0100 Subject: [PATCH 1/4] Check reference_id in descriptor matches vector --- cpp/map_closures/MapClosures.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cpp/map_closures/MapClosures.cpp b/cpp/map_closures/MapClosures.cpp index a6f8c62..8eff340 100644 --- a/cpp/map_closures/MapClosures.cpp +++ b/cpp/map_closures/MapClosures.cpp @@ -110,7 +110,12 @@ void MapClosures::MatchAndAddToDatabase(const int id, } ClosureCandidate MapClosures::ValidateClosure(const int reference_id, const int query_id) const { - const Tree::MatchVector &matches = descriptor_matches_.at(reference_id); + auto it = descriptor_matches_.find(reference_id); + if (it == descriptor_matches_.end()) { + return ClosureCandidate(); + } + + const Tree::MatchVector &matches = it->second; const size_t num_matches = matches.size(); ClosureCandidate closure; @@ -167,5 +172,4 @@ std::vector MapClosures::GetTopKClosures( } return closures; } - } // namespace map_closures From 0bc82d20be5db794d31f5181cd5664de1ae43125 Mon Sep 17 00:00:00 2001 From: Alberto Giacalone Date: Mon, 10 Nov 2025 14:16:41 +0100 Subject: [PATCH 2/4] Spacing --- cpp/map_closures/MapClosures.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/map_closures/MapClosures.cpp b/cpp/map_closures/MapClosures.cpp index 8eff340..40d80b4 100644 --- a/cpp/map_closures/MapClosures.cpp +++ b/cpp/map_closures/MapClosures.cpp @@ -172,4 +172,5 @@ std::vector MapClosures::GetTopKClosures( } return closures; } + } // namespace map_closures From b587abcf195a1c827316e8fc231c7a24833006a1 Mon Sep 17 00:00:00 2001 From: Alberto Giacalone Date: Mon, 24 Nov 2025 16:06:45 +0100 Subject: [PATCH 3/4] Trailing whitespace --- cpp/map_closures/MapClosures.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/map_closures/MapClosures.cpp b/cpp/map_closures/MapClosures.cpp index 40d80b4..cca33ae 100644 --- a/cpp/map_closures/MapClosures.cpp +++ b/cpp/map_closures/MapClosures.cpp @@ -114,7 +114,7 @@ ClosureCandidate MapClosures::ValidateClosure(const int reference_id, const int if (it == descriptor_matches_.end()) { return ClosureCandidate(); } - + const Tree::MatchVector &matches = it->second; const size_t num_matches = matches.size(); From 0ac8d75b8951df52d1660129de66dfe72b157cd4 Mon Sep 17 00:00:00 2001 From: Alberto Giacalone Date: Mon, 24 Nov 2025 16:07:19 +0100 Subject: [PATCH 4/4] Constant iterator --- cpp/map_closures/MapClosures.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/map_closures/MapClosures.cpp b/cpp/map_closures/MapClosures.cpp index cca33ae..85d34dd 100644 --- a/cpp/map_closures/MapClosures.cpp +++ b/cpp/map_closures/MapClosures.cpp @@ -110,7 +110,7 @@ void MapClosures::MatchAndAddToDatabase(const int id, } ClosureCandidate MapClosures::ValidateClosure(const int reference_id, const int query_id) const { - auto it = descriptor_matches_.find(reference_id); + const auto it = descriptor_matches_.find(reference_id); if (it == descriptor_matches_.end()) { return ClosureCandidate(); }