]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: trade a map<> for a plain arrary
authorKefu Chai <kchai@redhat.com>
Mon, 16 Aug 2021 12:03:22 +0000 (20:03 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 16 Aug 2021 12:12:19 +0000 (20:12 +0800)
for two reasons

* to avoid the overhead of copying the loop variables.
* no need to keep a map<> if what we need is just an arrary
* no need to keep a string if what we need is but an array of char

also mark the array "const", as we never change it.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/librbd/io/QosImageDispatch.cc

index 51b9f399239f075e4c1744be9719a0d581ea74c7..96be195c59a191ddb47d13904d9ce5183c8d51db 100644 (file)
@@ -6,7 +6,7 @@
 #include "librbd/AsioEngine.h"
 #include "librbd/ImageCtx.h"
 #include "librbd/io/FlushTracker.h"
-#include <map>
+#include <utility>
 
 #define dout_subsys ceph_subsys_rbd
 #undef dout_prefix
@@ -36,7 +36,7 @@ uint64_t calculate_tokens(bool read_op, uint64_t extent_length, uint64_t flag) {
   return (((flag & IMAGE_DISPATCH_FLAG_QOS_BPS_MASK) != 0) ? extent_length : 1);
 }
 
-static std::map<uint64_t, std::string> throttle_flags = {
+static const std::pair<uint64_t, const char*> throttle_flags[] = {
   {IMAGE_DISPATCH_FLAG_QOS_IOPS_THROTTLE,       "rbd_qos_iops_throttle"       },
   {IMAGE_DISPATCH_FLAG_QOS_BPS_THROTTLE,        "rbd_qos_bps_throttle"        },
   {IMAGE_DISPATCH_FLAG_QOS_READ_IOPS_THROTTLE,  "rbd_qos_read_iops_throttle"  },