[m-rev.] for review: speed up uint32 to string conversion

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed Oct 27 22:02:16 AEDT 2021



On Wed, 27 Oct 2021 21:56:35 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
> > Agreed, but it should be done in two phases. First, find the best replacement,
> > and then, roll it out to all related conversion functions, not just
> > the one for uint32s.
> 
> I was intending to do this for all integer types, not just uint32s.
> (I started with uints32s because it made comparison with the non-C
> grades easier.)

I figured as much.

> > The best approach *may* differ between e.g.  uintN for different N,
> > but probably not by much.
> 
> I suspect there may be some difference between the 32-bit and 64-bit
> cases

I meant two things by "the best approach may differ":

- For uint16, there is no point in checked whether you need 6 or more digits,

- and that because of this, the relative merits of the loop approach (a2)
  and the if-then-else-chain approach (a1) may change.

> and that the other cases can be handled by casting and then
> calling the 32-bit or 64-bit case appropriate.

Because of the above, handling 8 and 16 bit cases by casting to 32
would leave performance on the table.
 
> Unless you have any objections I will commit this diff and then add
> additional benchmarks and tests for the other integer types.

No objection.

Zoltan.




More information about the reviews mailing list