mirror of
https://github.com/transmission/transmission.git
synced 2026-02-15 07:26:49 +00:00
fix: revert "perf: improve IPv4 tr_address comparison" (#5709)
* Revert "perf: improve IPv4 `tr_address` comparison (#5651)"
This reverts commit 70decc1d9d.
* added tests
* add ipv4 equal test and std header
This commit is contained in:
@@ -596,9 +596,7 @@ int tr_address::compare(tr_address const& that) const noexcept // <=>
|
||||
return this->is_ipv4() ? 1 : -1;
|
||||
}
|
||||
|
||||
// in_addr_t is by definition uint32_t, so we convert it to int64_t,
|
||||
// the smallest signed integer type that can contain all values of uint32_t.
|
||||
return this->is_ipv4() ? static_cast<int>(int64_t{ ntohl(this->addr.addr4.s_addr) } - ntohl(that.addr.addr4.s_addr)) :
|
||||
return this->is_ipv4() ? memcmp(&this->addr.addr4, &that.addr.addr4, sizeof(this->addr.addr4)) :
|
||||
memcmp(&this->addr.addr6.s6_addr, &that.addr.addr6.s6_addr, sizeof(this->addr.addr6.s6_addr));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user