From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qvsx4-0002zS-Ay for qemu-devel@nongnu.org; Tue, 23 Aug 2011 11:31:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qvsx3-0002Sp-BA for qemu-devel@nongnu.org; Tue, 23 Aug 2011 11:31:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qvsx3-0002Sl-2x for qemu-devel@nongnu.org; Tue, 23 Aug 2011 11:31:41 -0400 Message-ID: <4E53C88D.2090708@redhat.com> Date: Tue, 23 Aug 2011 17:34:37 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1314105682-28396-1-git-send-email-freddy77@gmail.com> <1314105682-28396-15-git-send-email-freddy77@gmail.com> In-Reply-To: <1314105682-28396-15-git-send-email-freddy77@gmail.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 14/15] qcow2: small math optimization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Frediano Ziglio Cc: qemu-devel@nongnu.org Am 23.08.2011 15:21, schrieb Frediano Ziglio: > Signed-off-by: Frediano Ziglio > --- > block/qcow2-refcount.c | 5 +---- > 1 files changed, 1 insertions(+), 4 deletions(-) > > diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c > index 2a915be..0f9a64a 100644 > --- a/block/qcow2-refcount.c > +++ b/block/qcow2-refcount.c > @@ -140,10 +140,7 @@ static unsigned int next_refcount_table_size(BDRVQcowState *s, > static int in_same_refcount_block(BDRVQcowState *s, uint64_t offset_a, > uint64_t offset_b) > { > - uint64_t block_a = offset_a >> (2 * s->cluster_bits - REFCOUNT_SHIFT); > - uint64_t block_b = offset_b >> (2 * s->cluster_bits - REFCOUNT_SHIFT); > - > - return (block_a == block_b); > + return ((offset_a ^ offset_b) >> (2 * s->cluster_bits - REFCOUNT_SHIFT)) == 0; > } Depending on whether the compiler is smart enough this will or will not change performance. However, even if we assume that it's a slight improvement, this is in a function that is hardly ever run and the optimisation comes with a high cost in terms of readability. I wouldn't do this. Kevin