From: Kefu Chai Date: Mon, 16 Aug 2021 12:03:22 +0000 (+0800) Subject: librbd: trade a map<> for a plain arrary X-Git-Tag: v17.1.0~1056^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c4b213984f48baa00fc038397f0ab368f0e04f28;p=ceph.git librbd: trade a map<> for a plain arrary 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 --- diff --git a/src/librbd/io/QosImageDispatch.cc b/src/librbd/io/QosImageDispatch.cc index 51b9f399239f..96be195c59a1 100644 --- a/src/librbd/io/QosImageDispatch.cc +++ b/src/librbd/io/QosImageDispatch.cc @@ -6,7 +6,7 @@ #include "librbd/AsioEngine.h" #include "librbd/ImageCtx.h" #include "librbd/io/FlushTracker.h" -#include +#include #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 throttle_flags = { +static const std::pair 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" },