Optimize FullRemoteFileLocation comparison operators.
This commit is contained in:
parent
70db527023
commit
c920536260
@ -524,25 +524,17 @@ class FullRemoteFileLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const FullRemoteFileLocation &other) const {
|
bool operator<(const FullRemoteFileLocation &other) const {
|
||||||
if (key_type() != other.key_type()) {
|
auto lhs_key_type = key_type();
|
||||||
return key_type() < other.key_type();
|
auto rhs_key_type = other.key_type();
|
||||||
|
if (lhs_key_type != rhs_key_type) {
|
||||||
|
return lhs_key_type < rhs_key_type;
|
||||||
}
|
}
|
||||||
if (dc_id_ != other.dc_id_) {
|
if (dc_id_ != other.dc_id_) {
|
||||||
return dc_id_ < other.dc_id_;
|
return dc_id_ < other.dc_id_;
|
||||||
}
|
}
|
||||||
switch (location_type()) {
|
return variant_ < other.variant_;
|
||||||
case LocationType::Photo:
|
|
||||||
return photo() < other.photo();
|
|
||||||
case LocationType::Common:
|
|
||||||
return common() < other.common();
|
|
||||||
case LocationType::Web:
|
|
||||||
return web() < other.web();
|
|
||||||
case LocationType::None:
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const FullRemoteFileLocation &other) const {
|
bool operator==(const FullRemoteFileLocation &other) const {
|
||||||
if (key_type() != other.key_type()) {
|
if (key_type() != other.key_type()) {
|
||||||
return false;
|
return false;
|
||||||
@ -550,18 +542,7 @@ class FullRemoteFileLocation {
|
|||||||
if (dc_id_ != other.dc_id_) {
|
if (dc_id_ != other.dc_id_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (location_type()) {
|
return variant_ == other.variant_;
|
||||||
case LocationType::Photo:
|
|
||||||
return photo() == other.photo();
|
|
||||||
case LocationType::Common:
|
|
||||||
return common() == other.common();
|
|
||||||
case LocationType::Web:
|
|
||||||
return web() == other.web();
|
|
||||||
case LocationType::None:
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int32 KEY_MAGIC = 0x64374632;
|
static const int32 KEY_MAGIC = 0x64374632;
|
||||||
|
Loading…
Reference in New Issue
Block a user