Denest operator< for clarity

This commit is contained in:
Tyler Neely 2022-08-02 07:06:43 +00:00
parent 4d8f9ea821
commit 3b44ef70b6
2 changed files with 14 additions and 10 deletions

View File

@ -44,13 +44,15 @@ struct Address {
/// unique_id is most dominant for ordering, then last_known_ip, then last_known_port
bool operator<(const Address &other) const {
if (unique_id == other.unique_id) {
if (last_known_ip == other.last_known_ip) {
return last_known_port < other.last_known_port;
}
if (unique_id != other.unique_id) {
return unique_id < other.unique_id;
}
if (last_known_ip != other.last_known_ip) {
return last_known_ip < other.last_known_ip;
}
return unique_id < other.unique_id;
return last_known_port < other.last_known_port;
}
std::string ToString() const {

View File

@ -44,13 +44,15 @@ struct PromiseKey {
public:
bool operator<(const PromiseKey &other) const {
if (requester_address == other.requester_address) {
if (request_id == other.request_id) {
return replier_address < other.replier_address;
}
if (requester_address != other.requester_address) {
return requester_address < other.requester_address;
}
if (request_id != other.request_id) {
return request_id < other.request_id;
}
return requester_address < other.requester_address;
return replier_address < other.replier_address;
}
};