From: xie xingguo Date: Sat, 30 Jul 2016 07:26:30 +0000 (+0800) Subject: common/hobject: make set_bitwise_key_u32() faster X-Git-Tag: ses5-milestone5~179^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=895a9d920645ad7f09439103f190921ac765c712;p=ceph.git common/hobject: make set_bitwise_key_u32() faster 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 --- diff --git a/src/common/hobject.h b/src/common/hobject.h index 2e5d6fe9715..d82157a7bb1 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -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 {