]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg: using switch-case in place of if-else. 38811/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Fri, 8 Jan 2021 08:11:27 +0000 (16:11 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Fri, 8 Jan 2021 08:11:27 +0000 (16:11 +0800)
For point of performance, swith-case is better than if-else for
blackhole check.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/msg/Connection.cc

index 21f147b8034963aa2439728b5b2d5a6edb096d96..9183871b59429ec66add6b2ddf8c3c50427d3841 100644 (file)
@@ -7,8 +7,17 @@
 
 bool Connection::is_blackhole() const {
   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) ||
-      (conf->ms_blackhole_mds && peer_type == CEPH_ENTITY_TYPE_MDS) ||
-      (conf->ms_blackhole_client && peer_type == CEPH_ENTITY_TYPE_CLIENT));
+
+  switch (peer_type) {
+  case CEPH_ENTITY_TYPE_MON:
+    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;
+  }
 }