apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lucian Adrian Grijincu" <lucian.griji...@gmail.com>
Subject Re: [PATCH] vformatter cleanups (related to PR 42250)
Date Fri, 27 Apr 2007 03:14:52 GMT
in apr-conv10-faster.patch you added:

static const char digits[] = "0123456789";
*--p = digits[magnitude % 10];

Why is this faster than:
*--p = (char) '0' + (magnitude % 10); ?

For your "faster" version, under the hood, the C compiler adds
(magnitude % 10) to the address of digits and then copies the contents
of the memory location represented by the sum's result into *--p.

My version just adds (magnitude % 10) to '0' and stores the result in *--p.

Am I missing something here?

--
Lucian Adrian Grijincu

On 4/27/07, Davi Arnaut <davi@haxent.com.br> wrote:
> Hi,
>
> A few cleanups for the vformatter code. Each patch has a description.
>
> --
> Davi Arnaut
>
>

Mime
View raw message