]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/hobject: make set_bitwise_key_u32() faster
authorxie xingguo <xie.xingguo@zte.com.cn>
Sat, 30 Jul 2016 07:26:30 +0000 (15:26 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 1 Aug 2016 22:54:57 +0000 (06:54 +0800)
For now BlueStore is the only caller of set_bitwise_key_u32(),
and it will always passed in hash_reverse_bits.

Since this is one of the basic and key method of BlueStore, it makes
sense to make it a little faster.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/common/hobject.h

index 2e5d6fe971546d96f2258bd1374067d85abaef7c..d82157a7bb16f342da1f9f3d0e2d40473f0c5d8f 100644 (file)
@@ -244,13 +244,18 @@ public:
     return max ? 0x100000000ull : hash_reverse_bits;
   }
 
+  // please remember to update set_bitwise_key_u32() also
+  // once you change build_hash_cache()
   void build_hash_cache() {
     nibblewise_key_cache = _reverse_nibbles(hash);
     hash_reverse_bits = _reverse_bits(hash);
   }
   void set_bitwise_key_u32(uint32_t value) {
     hash = _reverse_bits(value);
-    build_hash_cache();
+    // below is identical to build_hash_cache() and shall be
+    // updated correspondingly if you change build_hash_cache() 
+    nibblewise_key_cache = _reverse_nibbles(hash);
+    hash_reverse_bits = value;
   }
 
   const string& get_effective_key() const {