]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: use std::countl_zero() when appropriate
authorKefu Chai <tchaikov@gmail.com>
Sun, 21 Aug 2022 16:41:52 +0000 (00:41 +0800)
committerKefu Chai <tchaikov@gmail.com>
Mon, 22 Aug 2022 10:03:59 +0000 (18:03 +0800)
prefer the facilities provided by standard library over the homebrew
ones for better readability and maintainability.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/os/bluestore/Allocator.cc

index fb2356c90f8356a8c661f11fe7bbfdb28de2a4f7..4f835d66869f42ca8d10dbad3cb99f26f755ea19 100644 (file)
@@ -2,6 +2,7 @@
 // vim: ts=8 sw=2 smarttab
 
 #include "Allocator.h"
+#include <bit>
 #include "StupidAllocator.h"
 #include "BitmapAllocator.h"
 #include "AvlAllocator.h"
@@ -194,7 +195,7 @@ double Allocator::get_fragmentation_score()
   size_t sum = 0;
 
   auto get_score = [&](size_t v) -> double {
-    size_t sc = sizeof(v) * 8 - clz(v) - 1; //assign to grade depending on log2(len)
+    size_t sc = sizeof(v) * 8 - std::countl_zero(v) - 1; //assign to grade depending on log2(len)
     while (scales.size() <= sc + 1) {
       //unlikely expand scales vector
       scales.push_back(scales[scales.size() - 1] * double_size_worth);