core: make get_trip_by_uniq_id a member of trip_table

Don't access the global trip_table in an attempt to cut down
on implicit accesses of global variables.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-02 00:36:20 +02:00 committed by bstoeger
parent eacad89531
commit 71518fa77e
3 changed files with 6 additions and 7 deletions

View file

@ -138,11 +138,10 @@ std::pair<dive_trip *, std::unique_ptr<dive_trip>> get_trip_for_new_dive(const s
}
/* lookup of trip in main trip_table based on its id */
dive_trip *get_trip_by_uniq_id(int tripId)
dive_trip *trip_table::get_by_uniq_id(int tripId) const
{
auto it = std::find_if(divelog.trips->begin(), divelog.trips->end(),
[tripId](auto &t) { return t->id == tripId; });
return it != divelog.trips->end() ? it->get() : nullptr;
auto it = std::find_if(begin(), end(), [tripId](auto &t) { return t->id == tripId; });
return it != end() ? it->get() : nullptr;
}
/* Check if two trips overlap time-wise up to trip threshold. */