From: Kefu Chai Date: Thu, 2 Nov 2017 07:20:24 +0000 (+0800) Subject: msg/async: use bitset<> to do the popcnt X-Git-Tag: v13.0.1~317^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=79476d4e25ec6ef50859cfc80b1a504f5e910cd7;p=ceph.git msg/async: use bitset<> to do the popcnt libstdc++ uses popcnt to count the bits. it's faster and simpler. Signed-off-by: Kefu Chai --- diff --git a/src/msg/async/dpdk/dpdk_rte.cc b/src/msg/async/dpdk/dpdk_rte.cc index 6510df103b20..89a69e527539 100644 --- a/src/msg/async/dpdk/dpdk_rte.cc +++ b/src/msg/async/dpdk/dpdk_rte.cc @@ -16,6 +16,8 @@ * under the License. */ +#include + #include #include #include @@ -40,10 +42,7 @@ namespace dpdk { static int bitcount(unsigned n) { - unsigned int c =0 ; - for (c = 0; n; ++c) - n &= (n -1); - return c; + return std::bitset{n}.count(); } int eal::init(CephContext *c)