Skip to content

Commit bf55aea

Browse files
Fabian Schenkmeta-codesync[bot]
authored andcommitted
reserve in tracks_manager
Differential Revision: D108284677 fbshipit-source-id: 0928f55457482d4899c6d478520103d40f801b76
1 parent 48fd563 commit bf55aea

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

opensfm/src/map/src/tracks_manager.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ TracksManager TracksManager::ConstructSubTracksManager(
260260
const std::vector<TrackId>& tracks,
261261
const std::vector<ShotId>& shots) const {
262262
std::unordered_set<TrackId> shotsTmp;
263+
shotsTmp.reserve(shots.size());
263264
for (const auto& id : shots) {
264265
shotsTmp.insert(id);
265266
}
@@ -308,6 +309,7 @@ TracksManager::GetAllPairsConnectivity(
308309

309310
std::vector<TrackId> tracks_to_use;
310311
if (tracks.empty()) {
312+
tracks_to_use.reserve(shots_per_track_.size());
311313
for (const auto& [track_id, observations] : shots_per_track_) {
312314
tracks_to_use.push_back(track_id);
313315
}
@@ -317,10 +319,12 @@ TracksManager::GetAllPairsConnectivity(
317319

318320
std::unordered_set<ShotId> shots_to_use;
319321
if (shots.empty()) {
322+
shots_to_use.reserve(tracks_per_shot_.size());
320323
for (const auto& [shot_id, observations] : tracks_per_shot_) {
321324
shots_to_use.insert(shot_id);
322325
}
323326
} else {
327+
shots_to_use.reserve(shots.size());
324328
for (const auto& shot : shots) {
325329
shots_to_use.insert(shot);
326330
}

0 commit comments

Comments
 (0)