msg: using switch-case in place of if-else.

For point of performance, swith-case is better than if-else for
blackhole check.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
This commit is contained in:
Jianpeng Ma 2021-01-08 16:11:27 +08:00
parent 485ddccc35
commit 0471a2d6c9

View File

@ -7,8 +7,17 @@
bool Connection::is_blackhole() const { bool Connection::is_blackhole() const {
auto& conf = msgr->cct->_conf; auto& conf = msgr->cct->_conf;
return ((conf->ms_blackhole_mon && peer_type == CEPH_ENTITY_TYPE_MON) ||
(conf->ms_blackhole_osd && peer_type == CEPH_ENTITY_TYPE_OSD) || switch (peer_type) {
(conf->ms_blackhole_mds && peer_type == CEPH_ENTITY_TYPE_MDS) || case CEPH_ENTITY_TYPE_MON:
(conf->ms_blackhole_client && peer_type == CEPH_ENTITY_TYPE_CLIENT)); return conf->ms_blackhole_mon;
case CEPH_ENTITY_TYPE_OSD:
return conf->ms_blackhole_osd;
case CEPH_ENTITY_TYPE_MDS:
return conf->ms_blackhole_mds;
case CEPH_ENTITY_TYPE_CLIENT:
return conf->ms_blackhole_client;
default:
return false;
}
} }