From 9109f14ea10d6cd0dd0605a2e2b9ad8398cbf392 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Piotr=20Da=C5=82ek?= Date: Thu, 19 Nov 2015 10:57:46 +0100 Subject: [PATCH] common/hobject.h: don't reverse bits in zero MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Zero is passed in around 30% of all calls to _reverse_bits (and most of them during daemon startup). Optimize this by not doing anything in that special case and returning 0. Signed-off-by: Piotr Dałek --- src/common/hobject.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/hobject.h b/src/common/hobject.h index 4698756515556..601af40fa43f6 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -176,6 +176,8 @@ public: } static uint32_t _reverse_bits(uint32_t v) { + if (v == 0) + return v; // reverse bits // swap odd and even bits v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1); -- 2.39.5