From 33a8c1c6fcf91d6c51e8772e73c44a6d573446dc Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 2 Apr 2025 23:00:06 +0100 Subject: [PATCH] Codechange: Use default operator<=> to compare Linkgraph Hop. (#13944) --- src/linkgraph/refresh.cpp | 20 -------------------- src/linkgraph/refresh.h | 3 ++- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/linkgraph/refresh.cpp b/src/linkgraph/refresh.cpp index 1695671d86..1ffb1dda50 100644 --- a/src/linkgraph/refresh.cpp +++ b/src/linkgraph/refresh.cpp @@ -38,26 +38,6 @@ refresher.RefreshLinks(first, first, v->last_loading_station != StationID::Invalid() ? RefreshFlags{RefreshFlag::HasCargo} : RefreshFlags{}); } -/** - * Comparison operator to allow hops to be used in a std::set. - * @param other Other hop to be compared with. - * @return If this hop is "smaller" than the other (defined by from, to and cargo in this order). - */ -bool LinkRefresher::Hop::operator<(const Hop &other) const -{ - if (this->from < other.from) { - return true; - } else if (this->from > other.from) { - return false; - } - if (this->to < other.to) { - return true; - } else if (this->to > other.to) { - return false; - } - return this->cargo < other.cargo; -} - /** * Constructor for link refreshing algorithm. * @param vehicle Vehicle to refresh links for. diff --git a/src/linkgraph/refresh.h b/src/linkgraph/refresh.h index 31bc570897..5473cbf92c 100644 --- a/src/linkgraph/refresh.h +++ b/src/linkgraph/refresh.h @@ -73,7 +73,8 @@ protected: * @param cargo Cargo the consist is probably carrying when passing the hop. */ Hop(OrderID from, OrderID to, CargoType cargo) : from(from), to(to), cargo(cargo) {} - bool operator<(const Hop &other) const; + + constexpr auto operator<=>(const Hop &) const noexcept = default; }; typedef std::vector RefitList;